Crossfire Server, Trunk
json.hpp
Go to the documentation of this file.
1 /*
2  __ _____ _____ _____
3  __| | __| | | | JSON for Modern C++
4 | | |__ | | | | | | version 3.10.0
5 |_____|_____|_____|_|___| https://github.com/nlohmann/json
6 
7 Licensed under the MIT License <http://opensource.org/licenses/MIT>.
8 SPDX-License-Identifier: MIT
9 Copyright (c) 2013-2019 Niels Lohmann <http://nlohmann.me>.
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall be included in all
19 copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 SOFTWARE.
28 */
29 
30 #ifndef INCLUDE_NLOHMANN_JSON_HPP_
31 #define INCLUDE_NLOHMANN_JSON_HPP_
32 
33 #define NLOHMANN_JSON_VERSION_MAJOR 3
34 #define NLOHMANN_JSON_VERSION_MINOR 10
35 #define NLOHMANN_JSON_VERSION_PATCH 0
36 
37 #include <algorithm> // all_of, find, for_each
38 #include <cstddef> // nullptr_t, ptrdiff_t, size_t
39 #include <functional> // hash, less
40 #include <initializer_list> // initializer_list
41 #ifndef JSON_NO_IO
42  #include <iosfwd> // istream, ostream
43 #endif // JSON_NO_IO
44 #include <iterator> // random_access_iterator_tag
45 #include <memory> // unique_ptr
46 #include <numeric> // accumulate
47 #include <string> // string, stoi, to_string
48 #include <utility> // declval, forward, move, pair, swap
49 #include <vector> // vector
50 
51 // #include <nlohmann/adl_serializer.hpp>
52 
53 
54 #include <type_traits>
55 #include <utility>
56 
57 // #include <nlohmann/detail/conversions/from_json.hpp>
58 
59 
60 #include <algorithm> // transform
61 #include <array> // array
62 #include <forward_list> // forward_list
63 #include <iterator> // inserter, front_inserter, end
64 #include <map> // map
65 #include <string> // string
66 #include <tuple> // tuple, make_tuple
67 #include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
68 #include <unordered_map> // unordered_map
69 #include <utility> // pair, declval
70 #include <valarray> // valarray
71 
72 // #include <nlohmann/detail/exceptions.hpp>
73 
74 
75 #include <exception> // exception
76 #include <stdexcept> // runtime_error
77 #include <string> // to_string
78 #include <vector> // vector
79 
80 // #include <nlohmann/detail/value_t.hpp>
81 
82 
83 #include <array> // array
84 #include <cstddef> // size_t
85 #include <cstdint> // uint8_t
86 #include <string> // string
87 
88 namespace nlohmann
89 {
90 namespace detail
91 {
93 // JSON type enumeration //
95 
120 enum class value_t : std::uint8_t
121 {
122  null,
123  object,
124  array,
125  string,
126  boolean,
129  number_float,
130  binary,
131  discarded
132 };
133 
147 inline bool operator<(const value_t lhs, const value_t rhs) noexcept
148 {
149  static constexpr std::array<std::uint8_t, 9> order = {{
150  0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
151  1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
152  6 /* binary */
153  }
154  };
155 
156  const auto l_index = static_cast<std::size_t>(lhs);
157  const auto r_index = static_cast<std::size_t>(rhs);
158  return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
159 }
160 } // namespace detail
161 } // namespace nlohmann
162 
163 // #include <nlohmann/detail/string_escape.hpp>
164 
165 
166 #include <string>
167 // #include <nlohmann/detail/macro_scope.hpp>
168 
169 
170 #include <utility> // pair
171 // #include <nlohmann/thirdparty/hedley/hedley.hpp>
172 
173 
174 /* Hedley - https://nemequ.github.io/hedley
175  * Created by Evan Nemerson <evan@nemerson.com>
176  *
177  * To the extent possible under law, the author(s) have dedicated all
178  * copyright and related and neighboring rights to this software to
179  * the public domain worldwide. This software is distributed without
180  * any warranty.
181  *
182  * For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
183  * SPDX-License-Identifier: CC0-1.0
184  */
185 
186 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
187 #if defined(JSON_HEDLEY_VERSION)
188  #undef JSON_HEDLEY_VERSION
189 #endif
190 #define JSON_HEDLEY_VERSION 15
191 
192 #if defined(JSON_HEDLEY_STRINGIFY_EX)
193  #undef JSON_HEDLEY_STRINGIFY_EX
194 #endif
195 #define JSON_HEDLEY_STRINGIFY_EX(x) #x
196 
197 #if defined(JSON_HEDLEY_STRINGIFY)
198  #undef JSON_HEDLEY_STRINGIFY
199 #endif
200 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
201 
202 #if defined(JSON_HEDLEY_CONCAT_EX)
203  #undef JSON_HEDLEY_CONCAT_EX
204 #endif
205 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b
206 
207 #if defined(JSON_HEDLEY_CONCAT)
208  #undef JSON_HEDLEY_CONCAT
209 #endif
210 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
211 
212 #if defined(JSON_HEDLEY_CONCAT3_EX)
213  #undef JSON_HEDLEY_CONCAT3_EX
214 #endif
215 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
216 
217 #if defined(JSON_HEDLEY_CONCAT3)
218  #undef JSON_HEDLEY_CONCAT3
219 #endif
220 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
221 
222 #if defined(JSON_HEDLEY_VERSION_ENCODE)
223  #undef JSON_HEDLEY_VERSION_ENCODE
224 #endif
225 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
226 
227 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
228  #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
229 #endif
230 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
231 
232 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
233  #undef JSON_HEDLEY_VERSION_DECODE_MINOR
234 #endif
235 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
236 
237 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
238  #undef JSON_HEDLEY_VERSION_DECODE_REVISION
239 #endif
240 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
241 
242 #if defined(JSON_HEDLEY_GNUC_VERSION)
243  #undef JSON_HEDLEY_GNUC_VERSION
244 #endif
245 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
246  #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
247 #elif defined(__GNUC__)
248  #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
249 #endif
250 
251 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
252  #undef JSON_HEDLEY_GNUC_VERSION_CHECK
253 #endif
254 #if defined(JSON_HEDLEY_GNUC_VERSION)
255  #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
256 #else
257  #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
258 #endif
259 
260 #if defined(JSON_HEDLEY_MSVC_VERSION)
261  #undef JSON_HEDLEY_MSVC_VERSION
262 #endif
263 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
264  #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
265 #elif defined(_MSC_FULL_VER) && !defined(__ICL)
266  #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
267 #elif defined(_MSC_VER) && !defined(__ICL)
268  #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
269 #endif
270 
271 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
272  #undef JSON_HEDLEY_MSVC_VERSION_CHECK
273 #endif
274 #if !defined(JSON_HEDLEY_MSVC_VERSION)
275  #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
276 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
277  #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
278 #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
279  #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
280 #else
281  #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
282 #endif
283 
284 #if defined(JSON_HEDLEY_INTEL_VERSION)
285  #undef JSON_HEDLEY_INTEL_VERSION
286 #endif
287 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
288  #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
289 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
290  #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
291 #endif
292 
293 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
294  #undef JSON_HEDLEY_INTEL_VERSION_CHECK
295 #endif
296 #if defined(JSON_HEDLEY_INTEL_VERSION)
297  #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
298 #else
299  #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
300 #endif
301 
302 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
303  #undef JSON_HEDLEY_INTEL_CL_VERSION
304 #endif
305 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
306  #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
307 #endif
308 
309 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
310  #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
311 #endif
312 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
313  #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
314 #else
315  #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
316 #endif
317 
318 #if defined(JSON_HEDLEY_PGI_VERSION)
319  #undef JSON_HEDLEY_PGI_VERSION
320 #endif
321 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
322  #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
323 #endif
324 
325 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
326  #undef JSON_HEDLEY_PGI_VERSION_CHECK
327 #endif
328 #if defined(JSON_HEDLEY_PGI_VERSION)
329  #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
330 #else
331  #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
332 #endif
333 
334 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
335  #undef JSON_HEDLEY_SUNPRO_VERSION
336 #endif
337 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
338  #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)
339 #elif defined(__SUNPRO_C)
340  #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
341 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
342  #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)
343 #elif defined(__SUNPRO_CC)
344  #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
345 #endif
346 
347 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
348  #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
349 #endif
350 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
351  #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
352 #else
353  #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
354 #endif
355 
356 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
357  #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
358 #endif
359 #if defined(__EMSCRIPTEN__)
360  #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
361 #endif
362 
363 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
364  #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
365 #endif
366 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
367  #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
368 #else
369  #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
370 #endif
371 
372 #if defined(JSON_HEDLEY_ARM_VERSION)
373  #undef JSON_HEDLEY_ARM_VERSION
374 #endif
375 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
376  #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
377 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
378  #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
379 #endif
380 
381 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
382  #undef JSON_HEDLEY_ARM_VERSION_CHECK
383 #endif
384 #if defined(JSON_HEDLEY_ARM_VERSION)
385  #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386 #else
387  #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
388 #endif
389 
390 #if defined(JSON_HEDLEY_IBM_VERSION)
391  #undef JSON_HEDLEY_IBM_VERSION
392 #endif
393 #if defined(__ibmxl__)
394  #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
395 #elif defined(__xlC__) && defined(__xlC_ver__)
396  #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
397 #elif defined(__xlC__)
398  #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
399 #endif
400 
401 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
402  #undef JSON_HEDLEY_IBM_VERSION_CHECK
403 #endif
404 #if defined(JSON_HEDLEY_IBM_VERSION)
405  #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
406 #else
407  #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
408 #endif
409 
410 #if defined(JSON_HEDLEY_TI_VERSION)
411  #undef JSON_HEDLEY_TI_VERSION
412 #endif
413 #if \
414  defined(__TI_COMPILER_VERSION__) && \
415  ( \
416  defined(__TMS470__) || defined(__TI_ARM__) || \
417  defined(__MSP430__) || \
418  defined(__TMS320C2000__) \
419  )
420 #if (__TI_COMPILER_VERSION__ >= 16000000)
421  #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
422 #endif
423 #endif
424 
425 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
426  #undef JSON_HEDLEY_TI_VERSION_CHECK
427 #endif
428 #if defined(JSON_HEDLEY_TI_VERSION)
429  #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
430 #else
431  #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
432 #endif
433 
434 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
435  #undef JSON_HEDLEY_TI_CL2000_VERSION
436 #endif
437 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
438  #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
439 #endif
440 
441 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
442  #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
443 #endif
444 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
445  #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
446 #else
447  #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
448 #endif
449 
450 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
451  #undef JSON_HEDLEY_TI_CL430_VERSION
452 #endif
453 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
454  #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
455 #endif
456 
457 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
458  #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
459 #endif
460 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
461  #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
462 #else
463  #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
464 #endif
465 
466 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
467  #undef JSON_HEDLEY_TI_ARMCL_VERSION
468 #endif
469 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
470  #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
471 #endif
472 
473 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
474  #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
475 #endif
476 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
477  #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
478 #else
479  #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
480 #endif
481 
482 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
483  #undef JSON_HEDLEY_TI_CL6X_VERSION
484 #endif
485 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
486  #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
487 #endif
488 
489 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
490  #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
491 #endif
492 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
493  #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
494 #else
495  #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
496 #endif
497 
498 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
499  #undef JSON_HEDLEY_TI_CL7X_VERSION
500 #endif
501 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
502  #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
503 #endif
504 
505 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
506  #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
507 #endif
508 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
509  #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
510 #else
511  #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
512 #endif
513 
514 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
515  #undef JSON_HEDLEY_TI_CLPRU_VERSION
516 #endif
517 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
518  #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
519 #endif
520 
521 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
522  #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
523 #endif
524 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
525  #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
526 #else
527  #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
528 #endif
529 
530 #if defined(JSON_HEDLEY_CRAY_VERSION)
531  #undef JSON_HEDLEY_CRAY_VERSION
532 #endif
533 #if defined(_CRAYC)
534  #if defined(_RELEASE_PATCHLEVEL)
535  #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
536  #else
537  #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
538  #endif
539 #endif
540 
541 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
542  #undef JSON_HEDLEY_CRAY_VERSION_CHECK
543 #endif
544 #if defined(JSON_HEDLEY_CRAY_VERSION)
545  #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546 #else
547  #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
548 #endif
549 
550 #if defined(JSON_HEDLEY_IAR_VERSION)
551  #undef JSON_HEDLEY_IAR_VERSION
552 #endif
553 #if defined(__IAR_SYSTEMS_ICC__)
554  #if __VER__ > 1000
555  #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
556  #else
557  #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
558  #endif
559 #endif
560 
561 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
562  #undef JSON_HEDLEY_IAR_VERSION_CHECK
563 #endif
564 #if defined(JSON_HEDLEY_IAR_VERSION)
565  #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566 #else
567  #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
568 #endif
569 
570 #if defined(JSON_HEDLEY_TINYC_VERSION)
571  #undef JSON_HEDLEY_TINYC_VERSION
572 #endif
573 #if defined(__TINYC__)
574  #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
575 #endif
576 
577 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
578  #undef JSON_HEDLEY_TINYC_VERSION_CHECK
579 #endif
580 #if defined(JSON_HEDLEY_TINYC_VERSION)
581  #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
582 #else
583  #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
584 #endif
585 
586 #if defined(JSON_HEDLEY_DMC_VERSION)
587  #undef JSON_HEDLEY_DMC_VERSION
588 #endif
589 #if defined(__DMC__)
590  #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
591 #endif
592 
593 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
594  #undef JSON_HEDLEY_DMC_VERSION_CHECK
595 #endif
596 #if defined(JSON_HEDLEY_DMC_VERSION)
597  #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
598 #else
599  #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
600 #endif
601 
602 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
603  #undef JSON_HEDLEY_COMPCERT_VERSION
604 #endif
605 #if defined(__COMPCERT_VERSION__)
606  #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
607 #endif
608 
609 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
610  #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
611 #endif
612 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
613  #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
614 #else
615  #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
616 #endif
617 
618 #if defined(JSON_HEDLEY_PELLES_VERSION)
619  #undef JSON_HEDLEY_PELLES_VERSION
620 #endif
621 #if defined(__POCC__)
622  #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
623 #endif
624 
625 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
626  #undef JSON_HEDLEY_PELLES_VERSION_CHECK
627 #endif
628 #if defined(JSON_HEDLEY_PELLES_VERSION)
629  #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
630 #else
631  #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
632 #endif
633 
634 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
635  #undef JSON_HEDLEY_MCST_LCC_VERSION
636 #endif
637 #if defined(__LCC__) && defined(__LCC_MINOR__)
638  #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
639 #endif
640 
641 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
642  #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
643 #endif
644 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
645  #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
646 #else
647  #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
648 #endif
649 
650 #if defined(JSON_HEDLEY_GCC_VERSION)
651  #undef JSON_HEDLEY_GCC_VERSION
652 #endif
653 #if \
654  defined(JSON_HEDLEY_GNUC_VERSION) && \
655  !defined(__clang__) && \
656  !defined(JSON_HEDLEY_INTEL_VERSION) && \
657  !defined(JSON_HEDLEY_PGI_VERSION) && \
658  !defined(JSON_HEDLEY_ARM_VERSION) && \
659  !defined(JSON_HEDLEY_CRAY_VERSION) && \
660  !defined(JSON_HEDLEY_TI_VERSION) && \
661  !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
662  !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
663  !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
664  !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
665  !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
666  !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
667  !defined(__COMPCERT__) && \
668  !defined(JSON_HEDLEY_MCST_LCC_VERSION)
669  #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
670 #endif
671 
672 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
673  #undef JSON_HEDLEY_GCC_VERSION_CHECK
674 #endif
675 #if defined(JSON_HEDLEY_GCC_VERSION)
676  #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
677 #else
678  #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
679 #endif
680 
681 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
682  #undef JSON_HEDLEY_HAS_ATTRIBUTE
683 #endif
684 #if \
685  defined(__has_attribute) && \
686  ( \
687  (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
688  )
689 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
690 #else
691 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
692 #endif
693 
694 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
695  #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
696 #endif
697 #if defined(__has_attribute)
698  #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
699 #else
700  #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
701 #endif
702 
703 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
704  #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
705 #endif
706 #if defined(__has_attribute)
707  #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
708 #else
709  #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
710 #endif
711 
712 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
713  #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
714 #endif
715 #if \
716  defined(__has_cpp_attribute) && \
717  defined(__cplusplus) && \
718  (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
719  #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
720 #else
721  #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
722 #endif
723 
724 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
725  #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
726 #endif
727 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
728  #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
729 #elif \
730  !defined(JSON_HEDLEY_PGI_VERSION) && \
731  !defined(JSON_HEDLEY_IAR_VERSION) && \
732  (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
733  (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
734  #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
735 #else
736  #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
737 #endif
738 
739 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
740  #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
741 #endif
742 #if defined(__has_cpp_attribute) && defined(__cplusplus)
743  #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
744 #else
745  #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
746 #endif
747 
748 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
749  #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
750 #endif
751 #if defined(__has_cpp_attribute) && defined(__cplusplus)
752  #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
753 #else
754  #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
755 #endif
756 
757 #if defined(JSON_HEDLEY_HAS_BUILTIN)
758  #undef JSON_HEDLEY_HAS_BUILTIN
759 #endif
760 #if defined(__has_builtin)
761  #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
762 #else
763  #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
764 #endif
765 
766 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
767  #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
768 #endif
769 #if defined(__has_builtin)
770  #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
771 #else
772  #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
773 #endif
774 
775 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
776  #undef JSON_HEDLEY_GCC_HAS_BUILTIN
777 #endif
778 #if defined(__has_builtin)
779  #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
780 #else
781  #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
782 #endif
783 
784 #if defined(JSON_HEDLEY_HAS_FEATURE)
785  #undef JSON_HEDLEY_HAS_FEATURE
786 #endif
787 #if defined(__has_feature)
788  #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
789 #else
790  #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
791 #endif
792 
793 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
794  #undef JSON_HEDLEY_GNUC_HAS_FEATURE
795 #endif
796 #if defined(__has_feature)
797  #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
798 #else
799  #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
800 #endif
801 
802 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
803  #undef JSON_HEDLEY_GCC_HAS_FEATURE
804 #endif
805 #if defined(__has_feature)
806  #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
807 #else
808  #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
809 #endif
810 
811 #if defined(JSON_HEDLEY_HAS_EXTENSION)
812  #undef JSON_HEDLEY_HAS_EXTENSION
813 #endif
814 #if defined(__has_extension)
815  #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
816 #else
817  #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
818 #endif
819 
820 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
821  #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
822 #endif
823 #if defined(__has_extension)
824  #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
825 #else
826  #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
827 #endif
828 
829 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
830  #undef JSON_HEDLEY_GCC_HAS_EXTENSION
831 #endif
832 #if defined(__has_extension)
833  #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
834 #else
835  #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
836 #endif
837 
838 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
839  #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
840 #endif
841 #if defined(__has_declspec_attribute)
842  #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
843 #else
844  #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
845 #endif
846 
847 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
848  #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
849 #endif
850 #if defined(__has_declspec_attribute)
851  #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
852 #else
853  #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
854 #endif
855 
856 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
857  #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
858 #endif
859 #if defined(__has_declspec_attribute)
860  #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
861 #else
862  #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
863 #endif
864 
865 #if defined(JSON_HEDLEY_HAS_WARNING)
866  #undef JSON_HEDLEY_HAS_WARNING
867 #endif
868 #if defined(__has_warning)
869  #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
870 #else
871  #define JSON_HEDLEY_HAS_WARNING(warning) (0)
872 #endif
873 
874 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
875  #undef JSON_HEDLEY_GNUC_HAS_WARNING
876 #endif
877 #if defined(__has_warning)
878  #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
879 #else
880  #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
881 #endif
882 
883 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
884  #undef JSON_HEDLEY_GCC_HAS_WARNING
885 #endif
886 #if defined(__has_warning)
887  #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
888 #else
889  #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
890 #endif
891 
892 #if \
893  (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
894  defined(__clang__) || \
895  JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
896  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
897  JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
898  JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
899  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
900  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
901  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
902  JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
903  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
904  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
905  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
906  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
907  JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
908  JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
909  JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
910  (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
911  #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
912 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
913  #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
914 #else
915  #define JSON_HEDLEY_PRAGMA(value)
916 #endif
917 
918 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
919  #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
920 #endif
921 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
922  #undef JSON_HEDLEY_DIAGNOSTIC_POP
923 #endif
924 #if defined(__clang__)
925  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
926  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
927 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
928  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
929  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
930 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
931  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
932  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
933 #elif \
934  JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
935  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
936  #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
937  #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
938 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
939  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
940  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
941 #elif \
942  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
943  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
944  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
945  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
946  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
947  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
948  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
949  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
950 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
951  #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
952  #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
953 #else
954  #define JSON_HEDLEY_DIAGNOSTIC_PUSH
955  #define JSON_HEDLEY_DIAGNOSTIC_POP
956 #endif
957 
958 /* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for
959  HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
960 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
961  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
962 #endif
963 #if defined(__cplusplus)
964 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
965 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
966 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
967 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
968  JSON_HEDLEY_DIAGNOSTIC_PUSH \
969  _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
970  _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
971  _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
972  xpr \
973  JSON_HEDLEY_DIAGNOSTIC_POP
974 # else
975 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
976  JSON_HEDLEY_DIAGNOSTIC_PUSH \
977  _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
978  _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
979  xpr \
980  JSON_HEDLEY_DIAGNOSTIC_POP
981 # endif
982 # else
983 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
984  JSON_HEDLEY_DIAGNOSTIC_PUSH \
985  _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
986  xpr \
987  JSON_HEDLEY_DIAGNOSTIC_POP
988 # endif
989 # endif
990 #endif
991 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
992  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
993 #endif
994 
995 #if defined(JSON_HEDLEY_CONST_CAST)
996  #undef JSON_HEDLEY_CONST_CAST
997 #endif
998 #if defined(__cplusplus)
999 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1000 #elif \
1001  JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1002  JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1003  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1004 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1005  JSON_HEDLEY_DIAGNOSTIC_PUSH \
1006  JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1007  ((T) (expr)); \
1008  JSON_HEDLEY_DIAGNOSTIC_POP \
1009  }))
1010 #else
1011 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1012 #endif
1013 
1014 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
1015  #undef JSON_HEDLEY_REINTERPRET_CAST
1016 #endif
1017 #if defined(__cplusplus)
1018  #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1019 #else
1020  #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1021 #endif
1022 
1023 #if defined(JSON_HEDLEY_STATIC_CAST)
1024  #undef JSON_HEDLEY_STATIC_CAST
1025 #endif
1026 #if defined(__cplusplus)
1027  #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1028 #else
1029  #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1030 #endif
1031 
1032 #if defined(JSON_HEDLEY_CPP_CAST)
1033  #undef JSON_HEDLEY_CPP_CAST
1034 #endif
1035 #if defined(__cplusplus)
1036 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1037 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1038  JSON_HEDLEY_DIAGNOSTIC_PUSH \
1039  _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1040  ((T) (expr)) \
1041  JSON_HEDLEY_DIAGNOSTIC_POP
1042 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1043 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1044  JSON_HEDLEY_DIAGNOSTIC_PUSH \
1045  _Pragma("diag_suppress=Pe137") \
1046  JSON_HEDLEY_DIAGNOSTIC_POP
1047 # else
1048 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1049 # endif
1050 #else
1051 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1052 #endif
1053 
1054 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1055  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1056 #endif
1057 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1058  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1059 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1060  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1061 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1062  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1063 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1064  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1065 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1066  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1067 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1068  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1069 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1070  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1071 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1072  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1073 #elif \
1074  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1075  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1076  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1077  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1078  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1079  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1080  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1081  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1082  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1083  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1084  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1085  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1086 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1087  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1088 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1089  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1090 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1091  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1092 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1093  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1094 #else
1095  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1096 #endif
1097 
1098 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1099  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1100 #endif
1101 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1102  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1103 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1104  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1105 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1106  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1107 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1108  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1109 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1110  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1111 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1112  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1113 #elif \
1114  JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1115  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1116  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1117  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1118  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1119 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1120  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1121 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1122  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1123 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1124  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1125 #else
1126  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1127 #endif
1128 
1129 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1130  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1131 #endif
1132 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1133  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1134 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1135  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1136 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1137  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1138 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1139  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1140 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1141  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1142 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1143  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1144 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1145  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1146 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1147  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1148 #elif \
1149  JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1150  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1151  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1152  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1153 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1154  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1155 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1156  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1157 #else
1158  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1159 #endif
1160 
1161 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1162  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1163 #endif
1164 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1165  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1166 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1167  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1168 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1169  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1170 #else
1171  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1172 #endif
1173 
1174 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1175  #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1176 #endif
1177 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1178  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1179 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1180  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1181 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1182  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1183 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1184  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1185 #else
1186  #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1187 #endif
1188 
1189 #if defined(JSON_HEDLEY_DEPRECATED)
1190  #undef JSON_HEDLEY_DEPRECATED
1191 #endif
1192 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1193  #undef JSON_HEDLEY_DEPRECATED_FOR
1194 #endif
1195 #if \
1196  JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1197  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1198  #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1199  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1200 #elif \
1201  (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1202  JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1203  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1204  JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1205  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1206  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1207  JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1208  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1209  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1210  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1211  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1212  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1213  #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1214  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1215 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1216  #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1217  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1218 #elif \
1219  JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1220  JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1221  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1222  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1233  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1234  JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1235  #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1236  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1237 #elif \
1238  JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1239  JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1240  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1241  #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1242  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1243 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1244  #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1245  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1246 #else
1247  #define JSON_HEDLEY_DEPRECATED(since)
1248  #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1249 #endif
1250 
1251 #if defined(JSON_HEDLEY_UNAVAILABLE)
1252  #undef JSON_HEDLEY_UNAVAILABLE
1253 #endif
1254 #if \
1255  JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1256  JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1257  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1258  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1259  #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1260 #else
1261  #define JSON_HEDLEY_UNAVAILABLE(available_since)
1262 #endif
1263 
1264 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1265  #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1266 #endif
1267 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1268  #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1269 #endif
1270 #if \
1271  JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1272  JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1273  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1274  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1275  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1276  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1277  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1278  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1279  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1280  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1281  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1282  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1283  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1284  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1285  (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1286  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1287  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1288  #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1289  #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1290 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1291  #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1292  #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1293 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1294  #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1295  #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1296 #elif defined(_Check_return_) /* SAL */
1297  #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1298  #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1299 #else
1300  #define JSON_HEDLEY_WARN_UNUSED_RESULT
1301  #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1302 #endif
1303 
1304 #if defined(JSON_HEDLEY_SENTINEL)
1305  #undef JSON_HEDLEY_SENTINEL
1306 #endif
1307 #if \
1308  JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1309  JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1310  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1311  JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1312  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1313  #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1314 #else
1315  #define JSON_HEDLEY_SENTINEL(position)
1316 #endif
1317 
1318 #if defined(JSON_HEDLEY_NO_RETURN)
1319  #undef JSON_HEDLEY_NO_RETURN
1320 #endif
1321 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1322  #define JSON_HEDLEY_NO_RETURN __noreturn
1323 #elif \
1324  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1325  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1326  #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1327 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1328  #define JSON_HEDLEY_NO_RETURN _Noreturn
1329 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1330  #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1331 #elif \
1332  JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1333  JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1334  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1335  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1336  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1337  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1338  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1339  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1340  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1341  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1342  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1343  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1344  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1345  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1346  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1347  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1348  JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1349  #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1350 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1351  #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1352 #elif \
1353  JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1354  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1355  #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1356 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1357  #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1358 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1359  #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1360 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1361  #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1362 #else
1363  #define JSON_HEDLEY_NO_RETURN
1364 #endif
1365 
1366 #if defined(JSON_HEDLEY_NO_ESCAPE)
1367  #undef JSON_HEDLEY_NO_ESCAPE
1368 #endif
1369 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1370  #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1371 #else
1372  #define JSON_HEDLEY_NO_ESCAPE
1373 #endif
1374 
1375 #if defined(JSON_HEDLEY_UNREACHABLE)
1376  #undef JSON_HEDLEY_UNREACHABLE
1377 #endif
1378 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1379  #undef JSON_HEDLEY_UNREACHABLE_RETURN
1380 #endif
1381 #if defined(JSON_HEDLEY_ASSUME)
1382  #undef JSON_HEDLEY_ASSUME
1383 #endif
1384 #if \
1385  JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1386  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1387  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1388  #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1389 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1390  #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1391 #elif \
1392  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1393  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1394  #if defined(__cplusplus)
1395  #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1396  #else
1397  #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1398  #endif
1399 #endif
1400 #if \
1401  (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1402  JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1403  JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1404  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1405  JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1406  JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1407  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1408  #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1409 #elif defined(JSON_HEDLEY_ASSUME)
1410  #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1411 #endif
1412 #if !defined(JSON_HEDLEY_ASSUME)
1413  #if defined(JSON_HEDLEY_UNREACHABLE)
1414  #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1415  #else
1416  #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1417  #endif
1418 #endif
1419 #if defined(JSON_HEDLEY_UNREACHABLE)
1420  #if \
1421  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1422  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1423  #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1424  #else
1425  #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1426  #endif
1427 #else
1428  #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1429 #endif
1430 #if !defined(JSON_HEDLEY_UNREACHABLE)
1431  #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1432 #endif
1433 
1435 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1436  #pragma clang diagnostic ignored "-Wpedantic"
1437 #endif
1438 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1439  #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1440 #endif
1441 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1442  #if defined(__clang__)
1443  #pragma clang diagnostic ignored "-Wvariadic-macros"
1444  #elif defined(JSON_HEDLEY_GCC_VERSION)
1445  #pragma GCC diagnostic ignored "-Wvariadic-macros"
1446  #endif
1447 #endif
1448 #if defined(JSON_HEDLEY_NON_NULL)
1449  #undef JSON_HEDLEY_NON_NULL
1450 #endif
1451 #if \
1452  JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1453  JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1454  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1455  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1456  #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1457 #else
1458  #define JSON_HEDLEY_NON_NULL(...)
1459 #endif
1461 
1462 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1463  #undef JSON_HEDLEY_PRINTF_FORMAT
1464 #endif
1465 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1466  #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1467 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1468  #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1469 #elif \
1470  JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1471  JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1472  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473  JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1474  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1475  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1476  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1477  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1478  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1479  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1480  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1481  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1482  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1483  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1484  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1485  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1486  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1487  #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1488 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1489  #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1490 #else
1491  #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1492 #endif
1493 
1494 #if defined(JSON_HEDLEY_CONSTEXPR)
1495  #undef JSON_HEDLEY_CONSTEXPR
1496 #endif
1497 #if defined(__cplusplus)
1498  #if __cplusplus >= 201103L
1499  #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1500  #endif
1501 #endif
1502 #if !defined(JSON_HEDLEY_CONSTEXPR)
1503  #define JSON_HEDLEY_CONSTEXPR
1504 #endif
1505 
1506 #if defined(JSON_HEDLEY_PREDICT)
1507  #undef JSON_HEDLEY_PREDICT
1508 #endif
1509 #if defined(JSON_HEDLEY_LIKELY)
1510  #undef JSON_HEDLEY_LIKELY
1511 #endif
1512 #if defined(JSON_HEDLEY_UNLIKELY)
1513  #undef JSON_HEDLEY_UNLIKELY
1514 #endif
1515 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1516  #undef JSON_HEDLEY_UNPREDICTABLE
1517 #endif
1518 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1519  #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1520 #endif
1521 #if \
1522  (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1523  JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1524  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1525 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1526 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1527 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1528 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1529 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1530 #elif \
1531  (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1532  JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1533  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1534  (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1535  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1536  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1537  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1538  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1539  JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1540  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1541  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1542  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1543  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1544  JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1545  JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1546  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1547 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1548  (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1549 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1550  (__extension__ ({ \
1551  double hedley_probability_ = (probability); \
1552  ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1553  }))
1554 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1555  (__extension__ ({ \
1556  double hedley_probability_ = (probability); \
1557  ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1558  }))
1559 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1560 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1561 #else
1562 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1563 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1564 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1565 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1566 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1567 #endif
1568 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1569  #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1570 #endif
1571 
1572 #if defined(JSON_HEDLEY_MALLOC)
1573  #undef JSON_HEDLEY_MALLOC
1574 #endif
1575 #if \
1576  JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1577  JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1578  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1579  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1580  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1581  JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1582  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1583  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1584  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1585  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1586  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1587  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1588  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1589  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1590  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1591  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1592  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1593  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1594  #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1595 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1596  #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1597 #elif \
1598  JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1599  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1600  #define JSON_HEDLEY_MALLOC __declspec(restrict)
1601 #else
1602  #define JSON_HEDLEY_MALLOC
1603 #endif
1604 
1605 #if defined(JSON_HEDLEY_PURE)
1606  #undef JSON_HEDLEY_PURE
1607 #endif
1608 #if \
1609  JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1610  JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1611  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1612  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1613  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1614  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1615  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1616  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1617  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1618  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1619  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1620  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1621  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1622  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1623  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1624  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1625  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1626  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1627  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1628 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1629 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1630 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1631 #elif defined(__cplusplus) && \
1632  ( \
1633  JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1634  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1635  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1636  )
1637 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1638 #else
1639 # define JSON_HEDLEY_PURE
1640 #endif
1641 
1642 #if defined(JSON_HEDLEY_CONST)
1643  #undef JSON_HEDLEY_CONST
1644 #endif
1645 #if \
1646  JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1647  JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1648  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1649  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1650  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1651  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1652  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1653  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1654  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1655  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1656  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1657  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1658  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1659  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1660  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1661  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1662  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1663  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1664  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1665  #define JSON_HEDLEY_CONST __attribute__((__const__))
1666 #elif \
1667  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1668  #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1669 #else
1670  #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1671 #endif
1672 
1673 #if defined(JSON_HEDLEY_RESTRICT)
1674  #undef JSON_HEDLEY_RESTRICT
1675 #endif
1676 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1677  #define JSON_HEDLEY_RESTRICT restrict
1678 #elif \
1679  JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1680  JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1681  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1683  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1686  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1687  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1688  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1689  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1690  (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1691  JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1692  defined(__clang__) || \
1693  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1694  #define JSON_HEDLEY_RESTRICT __restrict
1695 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1696  #define JSON_HEDLEY_RESTRICT _Restrict
1697 #else
1698  #define JSON_HEDLEY_RESTRICT
1699 #endif
1700 
1701 #if defined(JSON_HEDLEY_INLINE)
1702  #undef JSON_HEDLEY_INLINE
1703 #endif
1704 #if \
1705  (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1706  (defined(__cplusplus) && (__cplusplus >= 199711L))
1707  #define JSON_HEDLEY_INLINE inline
1708 #elif \
1709  defined(JSON_HEDLEY_GCC_VERSION) || \
1710  JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1711  #define JSON_HEDLEY_INLINE __inline__
1712 #elif \
1713  JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1714  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1715  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1716  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1717  JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1718  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1719  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1720  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1721  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1722  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1723  #define JSON_HEDLEY_INLINE __inline
1724 #else
1725  #define JSON_HEDLEY_INLINE
1726 #endif
1727 
1728 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1729  #undef JSON_HEDLEY_ALWAYS_INLINE
1730 #endif
1731 #if \
1732  JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1733  JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1734  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1735  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1736  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1737  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1738  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1739  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1740  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1741  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1743  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1745  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1747  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1748  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1749  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1750  JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1751 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1752 #elif \
1753  JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1754  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1755 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1756 #elif defined(__cplusplus) && \
1757  ( \
1758  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1759  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1760  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1761  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1762  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1763  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1764  )
1765 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1766 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1767 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1768 #else
1769 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1770 #endif
1771 
1772 #if defined(JSON_HEDLEY_NEVER_INLINE)
1773  #undef JSON_HEDLEY_NEVER_INLINE
1774 #endif
1775 #if \
1776  JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1777  JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1778  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1779  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1780  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1781  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1782  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1783  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1784  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1785  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1786  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1787  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1788  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1789  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1790  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1791  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1792  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1793  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1794  JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1795  #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1796 #elif \
1797  JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1798  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1799  #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1800 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1801  #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1802 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1803  #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1804 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1805  #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1806 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1807  #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1808 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1809  #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1810 #else
1811  #define JSON_HEDLEY_NEVER_INLINE
1812 #endif
1813 
1814 #if defined(JSON_HEDLEY_PRIVATE)
1815  #undef JSON_HEDLEY_PRIVATE
1816 #endif
1817 #if defined(JSON_HEDLEY_PUBLIC)
1818  #undef JSON_HEDLEY_PUBLIC
1819 #endif
1820 #if defined(JSON_HEDLEY_IMPORT)
1821  #undef JSON_HEDLEY_IMPORT
1822 #endif
1823 #if defined(_WIN32) || defined(__CYGWIN__)
1824 # define JSON_HEDLEY_PRIVATE
1825 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1826 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1827 #else
1828 # if \
1829  JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1830  JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1831  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1832  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1833  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1834  JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1835  ( \
1836  defined(__TI_EABI__) && \
1837  ( \
1838  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1839  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1840  ) \
1841  ) || \
1842  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1843 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1844 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1845 # else
1846 # define JSON_HEDLEY_PRIVATE
1847 # define JSON_HEDLEY_PUBLIC
1848 # endif
1849 # define JSON_HEDLEY_IMPORT extern
1850 #endif
1851 
1852 #if defined(JSON_HEDLEY_NO_THROW)
1853  #undef JSON_HEDLEY_NO_THROW
1854 #endif
1855 #if \
1856  JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1857  JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1858  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1859  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1860  #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1861 #elif \
1862  JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1863  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1864  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1865  #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1866 #else
1867  #define JSON_HEDLEY_NO_THROW
1868 #endif
1869 
1870 #if defined(JSON_HEDLEY_FALL_THROUGH)
1871  #undef JSON_HEDLEY_FALL_THROUGH
1872 #endif
1873 #if \
1874  JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1875  JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1876  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877  #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1878 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1879  #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1880 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1881  #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1882 #elif defined(__fallthrough) /* SAL */
1883  #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1884 #else
1885  #define JSON_HEDLEY_FALL_THROUGH
1886 #endif
1887 
1888 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1889  #undef JSON_HEDLEY_RETURNS_NON_NULL
1890 #endif
1891 #if \
1892  JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1893  JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1894  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1895  #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1896 #elif defined(_Ret_notnull_) /* SAL */
1897  #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1898 #else
1899  #define JSON_HEDLEY_RETURNS_NON_NULL
1900 #endif
1901 
1902 #if defined(JSON_HEDLEY_ARRAY_PARAM)
1903  #undef JSON_HEDLEY_ARRAY_PARAM
1904 #endif
1905 #if \
1906  defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1907  !defined(__STDC_NO_VLA__) && \
1908  !defined(__cplusplus) && \
1909  !defined(JSON_HEDLEY_PGI_VERSION) && \
1910  !defined(JSON_HEDLEY_TINYC_VERSION)
1911  #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1912 #else
1913  #define JSON_HEDLEY_ARRAY_PARAM(name)
1914 #endif
1915 
1916 #if defined(JSON_HEDLEY_IS_CONSTANT)
1917  #undef JSON_HEDLEY_IS_CONSTANT
1918 #endif
1919 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1920  #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1921 #endif
1922 /* JSON_HEDLEY_IS_CONSTEXPR_ is for
1923  HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
1924 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1925  #undef JSON_HEDLEY_IS_CONSTEXPR_
1926 #endif
1927 #if \
1928  JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1929  JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1930  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1931  JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1932  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1933  JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1934  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1935  (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1936  JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1937  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1938  #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1939 #endif
1940 #if !defined(__cplusplus)
1941 # if \
1942  JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1943  JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1944  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1945  JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1946  JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1947  JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1948  JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1949 #if defined(__INTPTR_TYPE__)
1950  #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1951 #else
1952  #include <stdint.h>
1953  #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1954 #endif
1955 # elif \
1956  ( \
1957  defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1958  !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1959  !defined(JSON_HEDLEY_PGI_VERSION) && \
1960  !defined(JSON_HEDLEY_IAR_VERSION)) || \
1961  (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1962  JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1963  JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1964  JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1965  JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1966 #if defined(__INTPTR_TYPE__)
1967  #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1968 #else
1969  #include <stdint.h>
1970  #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1971 #endif
1972 # elif \
1973  defined(JSON_HEDLEY_GCC_VERSION) || \
1974  defined(JSON_HEDLEY_INTEL_VERSION) || \
1975  defined(JSON_HEDLEY_TINYC_VERSION) || \
1976  defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1977  JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1978  defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1979  defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1980  defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1981  defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1982  defined(__clang__)
1983 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1984  sizeof(void) != \
1985  sizeof(*( \
1986  1 ? \
1987  ((void*) ((expr) * 0L) ) : \
1988 ((struct { char v[sizeof(void) * 2]; } *) 1) \
1989  ) \
1990  ) \
1991  )
1992 # endif
1993 #endif
1994 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1995  #if !defined(JSON_HEDLEY_IS_CONSTANT)
1996  #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1997  #endif
1998  #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1999 #else
2000  #if !defined(JSON_HEDLEY_IS_CONSTANT)
2001  #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2002  #endif
2003  #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2004 #endif
2005 
2006 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2007  #undef JSON_HEDLEY_BEGIN_C_DECLS
2008 #endif
2009 #if defined(JSON_HEDLEY_END_C_DECLS)
2010  #undef JSON_HEDLEY_END_C_DECLS
2011 #endif
2012 #if defined(JSON_HEDLEY_C_DECL)
2013  #undef JSON_HEDLEY_C_DECL
2014 #endif
2015 #if defined(__cplusplus)
2016  #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2017  #define JSON_HEDLEY_END_C_DECLS }
2018  #define JSON_HEDLEY_C_DECL extern "C"
2019 #else
2020  #define JSON_HEDLEY_BEGIN_C_DECLS
2021  #define JSON_HEDLEY_END_C_DECLS
2022  #define JSON_HEDLEY_C_DECL
2023 #endif
2024 
2025 #if defined(JSON_HEDLEY_STATIC_ASSERT)
2026  #undef JSON_HEDLEY_STATIC_ASSERT
2027 #endif
2028 #if \
2029  !defined(__cplusplus) && ( \
2030  (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2031  (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2032  JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2033  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2034  defined(_Static_assert) \
2035  )
2036 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2037 #elif \
2038  (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2039  JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2040  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2041 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2042 #else
2043 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2044 #endif
2045 
2046 #if defined(JSON_HEDLEY_NULL)
2047  #undef JSON_HEDLEY_NULL
2048 #endif
2049 #if defined(__cplusplus)
2050  #if __cplusplus >= 201103L
2051  #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2052  #elif defined(NULL)
2053  #define JSON_HEDLEY_NULL NULL
2054  #else
2055  #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2056  #endif
2057 #elif defined(NULL)
2058  #define JSON_HEDLEY_NULL NULL
2059 #else
2060  #define JSON_HEDLEY_NULL ((void*) 0)
2061 #endif
2062 
2063 #if defined(JSON_HEDLEY_MESSAGE)
2064  #undef JSON_HEDLEY_MESSAGE
2065 #endif
2066 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2067 # define JSON_HEDLEY_MESSAGE(msg) \
2068  JSON_HEDLEY_DIAGNOSTIC_PUSH \
2069  JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2070  JSON_HEDLEY_PRAGMA(message msg) \
2071  JSON_HEDLEY_DIAGNOSTIC_POP
2072 #elif \
2073  JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2074  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2075 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2076 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2077 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2078 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2079 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2080 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2081 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2082 #else
2083 # define JSON_HEDLEY_MESSAGE(msg)
2084 #endif
2085 
2086 #if defined(JSON_HEDLEY_WARNING)
2087  #undef JSON_HEDLEY_WARNING
2088 #endif
2089 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2090 # define JSON_HEDLEY_WARNING(msg) \
2091  JSON_HEDLEY_DIAGNOSTIC_PUSH \
2092  JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2093  JSON_HEDLEY_PRAGMA(clang warning msg) \
2094  JSON_HEDLEY_DIAGNOSTIC_POP
2095 #elif \
2096  JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2097  JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2098  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2099 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2100 #elif \
2101  JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2102  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2103 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2104 #else
2105 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2106 #endif
2107 
2108 #if defined(JSON_HEDLEY_REQUIRE)
2109  #undef JSON_HEDLEY_REQUIRE
2110 #endif
2111 #if defined(JSON_HEDLEY_REQUIRE_MSG)
2112  #undef JSON_HEDLEY_REQUIRE_MSG
2113 #endif
2114 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2115 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2116 # define JSON_HEDLEY_REQUIRE(expr) \
2117  JSON_HEDLEY_DIAGNOSTIC_PUSH \
2118  _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2119  __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2120  JSON_HEDLEY_DIAGNOSTIC_POP
2121 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2122  JSON_HEDLEY_DIAGNOSTIC_PUSH \
2123  _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2124  __attribute__((diagnose_if(!(expr), msg, "error"))) \
2125  JSON_HEDLEY_DIAGNOSTIC_POP
2126 # else
2127 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2128 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2129 # endif
2130 #else
2131 # define JSON_HEDLEY_REQUIRE(expr)
2132 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2133 #endif
2134 
2135 #if defined(JSON_HEDLEY_FLAGS)
2136  #undef JSON_HEDLEY_FLAGS
2137 #endif
2138 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2139  #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2140 #else
2141  #define JSON_HEDLEY_FLAGS
2142 #endif
2143 
2144 #if defined(JSON_HEDLEY_FLAGS_CAST)
2145  #undef JSON_HEDLEY_FLAGS_CAST
2146 #endif
2147 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2148 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2149  JSON_HEDLEY_DIAGNOSTIC_PUSH \
2150  _Pragma("warning(disable:188)") \
2151  ((T) (expr)); \
2152  JSON_HEDLEY_DIAGNOSTIC_POP \
2153  }))
2154 #else
2155 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2156 #endif
2157 
2158 #if defined(JSON_HEDLEY_EMPTY_BASES)
2159  #undef JSON_HEDLEY_EMPTY_BASES
2160 #endif
2161 #if \
2162  (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2163  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2164  #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2165 #else
2166  #define JSON_HEDLEY_EMPTY_BASES
2167 #endif
2168 
2169 /* Remaining macros are deprecated. */
2170 
2171 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2172  #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2173 #endif
2174 #if defined(__clang__)
2175  #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2176 #else
2177  #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2178 #endif
2179 
2180 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2181  #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2182 #endif
2183 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2184 
2185 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2186  #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2187 #endif
2188 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2189 
2190 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2191  #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2192 #endif
2193 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2194 
2195 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2196  #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2197 #endif
2198 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2199 
2200 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2201  #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2202 #endif
2203 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2204 
2205 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2206  #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2207 #endif
2208 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2209 
2210 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2211  #undef JSON_HEDLEY_CLANG_HAS_WARNING
2212 #endif
2213 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2214 
2215 #endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */
2216 
2217 
2218 // This file contains all internal macro definitions
2219 // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
2220 
2221 // exclude unsupported compilers
2222 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2223  #if defined(__clang__)
2224  #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2225  #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2226  #endif
2227  #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2228  #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2229  #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2230  #endif
2231  #endif
2232 #endif
2233 
2234 // C++ language standard detection
2235 // if the user manually specified the used c++ version this is skipped
2236 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2237  #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2238  #define JSON_HAS_CPP_20
2239  #define JSON_HAS_CPP_17
2240  #define JSON_HAS_CPP_14
2241  #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2242  #define JSON_HAS_CPP_17
2243  #define JSON_HAS_CPP_14
2244  #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2245  #define JSON_HAS_CPP_14
2246  #endif
2247  // the cpp 11 flag is always specified because it is the minimal required version
2248  #define JSON_HAS_CPP_11
2249 #endif
2250 
2251 // disable documentation warnings on clang
2252 #if defined(__clang__)
2253  #pragma clang diagnostic push
2254  #pragma clang diagnostic ignored "-Wdocumentation"
2255  #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2256 #endif
2257 
2258 // allow to disable exceptions
2259 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2260  #define JSON_THROW(exception) throw exception
2261  #define JSON_TRY try
2262  #define JSON_CATCH(exception) catch(exception)
2263  #define JSON_INTERNAL_CATCH(exception) catch(exception)
2264 #else
2265  #include <cstdlib>
2266  #define JSON_THROW(exception) std::abort()
2267  #define JSON_TRY if(true)
2268  #define JSON_CATCH(exception) if(false)
2269  #define JSON_INTERNAL_CATCH(exception) if(false)
2270 #endif
2271 
2272 // override exception macros
2273 #if defined(JSON_THROW_USER)
2274  #undef JSON_THROW
2275  #define JSON_THROW JSON_THROW_USER
2276 #endif
2277 #if defined(JSON_TRY_USER)
2278  #undef JSON_TRY
2279  #define JSON_TRY JSON_TRY_USER
2280 #endif
2281 #if defined(JSON_CATCH_USER)
2282  #undef JSON_CATCH
2283  #define JSON_CATCH JSON_CATCH_USER
2284  #undef JSON_INTERNAL_CATCH
2285  #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2286 #endif
2287 #if defined(JSON_INTERNAL_CATCH_USER)
2288  #undef JSON_INTERNAL_CATCH
2289  #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2290 #endif
2291 
2292 // allow to override assert
2293 #if !defined(JSON_ASSERT)
2294  #include <cassert> // assert
2295  #define JSON_ASSERT(x) assert(x)
2296 #endif
2297 
2298 // allow to access some private functions (needed by the test suite)
2299 #if defined(JSON_TESTS_PRIVATE)
2300  #define JSON_PRIVATE_UNLESS_TESTED public
2301 #else
2302  #define JSON_PRIVATE_UNLESS_TESTED private
2303 #endif
2304 
2310 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2311  template<typename BasicJsonType> \
2312  inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2313  { \
2314  static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2315  static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2316  auto it = std::find_if(std::begin(m), std::end(m), \
2317  [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2318  { \
2319  return ej_pair.first == e; \
2320  }); \
2321  j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2322  } \
2323  template<typename BasicJsonType> \
2324  inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2325  { \
2326  static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2327  static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2328  auto it = std::find_if(std::begin(m), std::end(m), \
2329  [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2330  { \
2331  return ej_pair.second == j; \
2332  }); \
2333  e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2334  }
2335 
2336 // Ugly macros to avoid uglier copy-paste when specializing basic_json. They
2337 // may be removed in the future once the class is split.
2338 
2339 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2340  template<template<typename, typename, typename...> class ObjectType, \
2341  template<typename, typename...> class ArrayType, \
2342  class StringType, class BooleanType, class NumberIntegerType, \
2343  class NumberUnsignedType, class NumberFloatType, \
2344  template<typename> class AllocatorType, \
2345  template<typename, typename = void> class JSONSerializer, \
2346  class BinaryType>
2347 
2348 #define NLOHMANN_BASIC_JSON_TPL \
2349  basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2350  NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2351  AllocatorType, JSONSerializer, BinaryType>
2352 
2353 // Macros to simplify conversion from/to types
2354 
2355 #define NLOHMANN_JSON_EXPAND( x ) x
2356 #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
2357 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2358  NLOHMANN_JSON_PASTE64, \
2359  NLOHMANN_JSON_PASTE63, \
2360  NLOHMANN_JSON_PASTE62, \
2361  NLOHMANN_JSON_PASTE61, \
2362  NLOHMANN_JSON_PASTE60, \
2363  NLOHMANN_JSON_PASTE59, \
2364  NLOHMANN_JSON_PASTE58, \
2365  NLOHMANN_JSON_PASTE57, \
2366  NLOHMANN_JSON_PASTE56, \
2367  NLOHMANN_JSON_PASTE55, \
2368  NLOHMANN_JSON_PASTE54, \
2369  NLOHMANN_JSON_PASTE53, \
2370  NLOHMANN_JSON_PASTE52, \
2371  NLOHMANN_JSON_PASTE51, \
2372  NLOHMANN_JSON_PASTE50, \
2373  NLOHMANN_JSON_PASTE49, \
2374  NLOHMANN_JSON_PASTE48, \
2375  NLOHMANN_JSON_PASTE47, \
2376  NLOHMANN_JSON_PASTE46, \
2377  NLOHMANN_JSON_PASTE45, \
2378  NLOHMANN_JSON_PASTE44, \
2379  NLOHMANN_JSON_PASTE43, \
2380  NLOHMANN_JSON_PASTE42, \
2381  NLOHMANN_JSON_PASTE41, \
2382  NLOHMANN_JSON_PASTE40, \
2383  NLOHMANN_JSON_PASTE39, \
2384  NLOHMANN_JSON_PASTE38, \
2385  NLOHMANN_JSON_PASTE37, \
2386  NLOHMANN_JSON_PASTE36, \
2387  NLOHMANN_JSON_PASTE35, \
2388  NLOHMANN_JSON_PASTE34, \
2389  NLOHMANN_JSON_PASTE33, \
2390  NLOHMANN_JSON_PASTE32, \
2391  NLOHMANN_JSON_PASTE31, \
2392  NLOHMANN_JSON_PASTE30, \
2393  NLOHMANN_JSON_PASTE29, \
2394  NLOHMANN_JSON_PASTE28, \
2395  NLOHMANN_JSON_PASTE27, \
2396  NLOHMANN_JSON_PASTE26, \
2397  NLOHMANN_JSON_PASTE25, \
2398  NLOHMANN_JSON_PASTE24, \
2399  NLOHMANN_JSON_PASTE23, \
2400  NLOHMANN_JSON_PASTE22, \
2401  NLOHMANN_JSON_PASTE21, \
2402  NLOHMANN_JSON_PASTE20, \
2403  NLOHMANN_JSON_PASTE19, \
2404  NLOHMANN_JSON_PASTE18, \
2405  NLOHMANN_JSON_PASTE17, \
2406  NLOHMANN_JSON_PASTE16, \
2407  NLOHMANN_JSON_PASTE15, \
2408  NLOHMANN_JSON_PASTE14, \
2409  NLOHMANN_JSON_PASTE13, \
2410  NLOHMANN_JSON_PASTE12, \
2411  NLOHMANN_JSON_PASTE11, \
2412  NLOHMANN_JSON_PASTE10, \
2413  NLOHMANN_JSON_PASTE9, \
2414  NLOHMANN_JSON_PASTE8, \
2415  NLOHMANN_JSON_PASTE7, \
2416  NLOHMANN_JSON_PASTE6, \
2417  NLOHMANN_JSON_PASTE5, \
2418  NLOHMANN_JSON_PASTE4, \
2419  NLOHMANN_JSON_PASTE3, \
2420  NLOHMANN_JSON_PASTE2, \
2421  NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2422 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2423 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2424 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2425 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2426 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2427 #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)
2428 #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)
2429 #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)
2430 #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)
2431 #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)
2432 #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)
2433 #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)
2434 #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)
2435 #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)
2436 #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)
2437 #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)
2438 #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)
2439 #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)
2440 #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)
2441 #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)
2442 #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)
2443 #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)
2444 #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)
2445 #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)
2446 #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)
2447 #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)
2448 #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)
2449 #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)
2450 #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)
2451 #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)
2452 #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)
2453 #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)
2454 #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)
2455 #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)
2456 #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)
2457 #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)
2458 #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)
2459 #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)
2460 #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)
2461 #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)
2462 #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)
2463 #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)
2464 #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)
2465 #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)
2466 #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)
2467 #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)
2468 #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)
2469 #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)
2470 #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)
2471 #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)
2472 #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)
2473 #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)
2474 #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)
2475 #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)
2476 #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)
2477 #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)
2478 #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)
2479 #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)
2480 #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)
2481 #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)
2482 #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)
2483 #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)
2484 #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)
2485 
2486 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2487 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2488 
2494 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2495  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__)) } \
2496  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__)) }
2497 
2503 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2504  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__)) } \
2505  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__)) }
2506 
2507 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2508  #define JSON_USE_IMPLICIT_CONVERSIONS 1
2509 #endif
2510 
2511 #if JSON_USE_IMPLICIT_CONVERSIONS
2512  #define JSON_EXPLICIT
2513 #else
2514  #define JSON_EXPLICIT explicit
2515 #endif
2516 
2517 
2518 namespace nlohmann
2519 {
2520 namespace detail
2521 {
2522 
2536 inline void replace_substring(std::string& s, const std::string& f,
2537  const std::string& t)
2538 {
2539  JSON_ASSERT(!f.empty());
2540  for (auto pos = s.find(f); // find first occurrence of f
2541  pos != std::string::npos; // make sure f was found
2542  s.replace(pos, f.size(), t), // replace with t, and
2543  pos = s.find(f, pos + t.size())) // find next occurrence of f
2544  {}
2545 }
2546 
2554 inline std::string escape(std::string s)
2555 {
2556  replace_substring(s, "~", "~0");
2557  replace_substring(s, "/", "~1");
2558  return s;
2559 }
2560 
2568 static void unescape(std::string& s)
2569 {
2570  replace_substring(s, "~1", "/");
2571  replace_substring(s, "~0", "~");
2572 }
2573 
2574 } // namespace detail
2575 } // namespace nlohmann
2576 
2577 // #include <nlohmann/detail/input/position_t.hpp>
2578 
2579 
2580 #include <cstddef> // size_t
2581 
2582 namespace nlohmann
2583 {
2584 namespace detail
2585 {
2588 {
2590  std::size_t chars_read_total = 0;
2592  std::size_t chars_read_current_line = 0;
2594  std::size_t lines_read = 0;
2595 
2597  constexpr operator size_t() const
2598  {
2599  return chars_read_total;
2600  }
2601 };
2602 
2603 } // namespace detail
2604 } // namespace nlohmann
2605 
2606 // #include <nlohmann/detail/macro_scope.hpp>
2607 
2608 
2609 namespace nlohmann
2610 {
2611 namespace detail
2612 {
2614 // exceptions //
2616 
2645 class exception : public std::exception
2646 {
2647  public:
2649  const char* what() const noexcept override
2650  {
2651  return m.what();
2652  }
2653 
2655  const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
2656 
2657  protected:
2659  exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
2660 
2661  static std::string name(const std::string& ename, int id_)
2662  {
2663  return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
2664  }
2665 
2666  template<typename BasicJsonType>
2667  static std::string diagnostics(const BasicJsonType& leaf_element)
2668  {
2669 #if JSON_DIAGNOSTICS
2670  std::vector<std::string> tokens;
2671  for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent)
2672  {
2673  switch (current->m_parent->type())
2674  {
2675  case value_t::array:
2676  {
2677  for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2678  {
2679  if (&current->m_parent->m_value.array->operator[](i) == current)
2680  {
2681  tokens.emplace_back(std::to_string(i));
2682  break;
2683  }
2684  }
2685  break;
2686  }
2687 
2688  case value_t::object:
2689  {
2690  for (const auto& element : *current->m_parent->m_value.object)
2691  {
2692  if (&element.second == current)
2693  {
2694  tokens.emplace_back(element.first.c_str());
2695  break;
2696  }
2697  }
2698  break;
2699  }
2700 
2701  case value_t::null: // LCOV_EXCL_LINE
2702  case value_t::string: // LCOV_EXCL_LINE
2703  case value_t::boolean: // LCOV_EXCL_LINE
2704  case value_t::number_integer: // LCOV_EXCL_LINE
2705  case value_t::number_unsigned: // LCOV_EXCL_LINE
2706  case value_t::number_float: // LCOV_EXCL_LINE
2707  case value_t::binary: // LCOV_EXCL_LINE
2708  case value_t::discarded: // LCOV_EXCL_LINE
2709  default: // LCOV_EXCL_LINE
2710  break; // LCOV_EXCL_LINE
2711  }
2712  }
2713 
2714  if (tokens.empty())
2715  {
2716  return "";
2717  }
2718 
2719  return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2720  [](const std::string & a, const std::string & b)
2721  {
2722  return a + "/" + detail::escape(b);
2723  }) + ") ";
2724 #else
2725  static_cast<void>(leaf_element);
2726  return "";
2727 #endif
2728  }
2729 
2730  private:
2732  std::runtime_error m;
2733 };
2734 
2780 class parse_error : public exception
2781 {
2782  public:
2792  template<typename BasicJsonType>
2793  static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context)
2794  {
2795  std::string w = exception::name("parse_error", id_) + "parse error" +
2796  position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
2797  return parse_error(id_, pos.chars_read_total, w.c_str());
2798  }
2799 
2800  template<typename BasicJsonType>
2801  static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context)
2802  {
2803  std::string w = exception::name("parse_error", id_) + "parse error" +
2804  (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
2805  ": " + exception::diagnostics(context) + what_arg;
2806  return parse_error(id_, byte_, w.c_str());
2807  }
2808 
2818  const std::size_t byte;
2819 
2820  private:
2821  parse_error(int id_, std::size_t byte_, const char* what_arg)
2822  : exception(id_, what_arg), byte(byte_) {}
2823 
2824  static std::string position_string(const position_t& pos)
2825  {
2826  return " at line " + std::to_string(pos.lines_read + 1) +
2827  ", column " + std::to_string(pos.chars_read_current_line);
2828  }
2829 };
2830 
2869 {
2870  public:
2871  template<typename BasicJsonType>
2872  static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
2873  {
2874  std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
2875  return invalid_iterator(id_, w.c_str());
2876  }
2877 
2878  private:
2880  invalid_iterator(int id_, const char* what_arg)
2881  : exception(id_, what_arg) {}
2882 };
2883 
2923 class type_error : public exception
2924 {
2925  public:
2926  template<typename BasicJsonType>
2927  static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
2928  {
2929  std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
2930  return type_error(id_, w.c_str());
2931  }
2932 
2933  private:
2935  type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
2936 };
2937 
2971 class out_of_range : public exception
2972 {
2973  public:
2974  template<typename BasicJsonType>
2975  static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
2976  {
2977  std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
2978  return out_of_range(id_, w.c_str());
2979  }
2980 
2981  private:
2983  out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
2984 };
2985 
3010 class other_error : public exception
3011 {
3012  public:
3013  template<typename BasicJsonType>
3014  static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
3015  {
3016  std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
3017  return other_error(id_, w.c_str());
3018  }
3019 
3020  private:
3022  other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
3023 };
3024 } // namespace detail
3025 } // namespace nlohmann
3026 
3027 // #include <nlohmann/detail/macro_scope.hpp>
3028 
3029 // #include <nlohmann/detail/meta/cpp_future.hpp>
3030 
3031 
3032 #include <cstddef> // size_t
3033 #include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
3034 #include <utility> // index_sequence, make_index_sequence, index_sequence_for
3035 
3036 // #include <nlohmann/detail/macro_scope.hpp>
3037 
3038 
3039 namespace nlohmann
3040 {
3041 namespace detail
3042 {
3043 
3044 template<typename T>
3046 
3047 #ifdef JSON_HAS_CPP_14
3048 
3049 // the following utilities are natively available in C++14
3050 using std::enable_if_t;
3051 using std::index_sequence;
3054 
3055 #else
3056 
3057 // alias templates to reduce boilerplate
3058 template<bool B, typename T = void>
3060 
3061 // The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h
3062 // which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0.
3063 
3065 
3066 // integer_sequence
3067 //
3068 // Class template representing a compile-time integer sequence. An instantiation
3069 // of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its
3070 // type through its template arguments (which is a common need when
3071 // working with C++11 variadic templates). `absl::integer_sequence` is designed
3072 // to be a drop-in replacement for C++14's `std::integer_sequence`.
3073 //
3074 // Example:
3075 //
3076 // template< class T, T... Ints >
3077 // void user_function(integer_sequence<T, Ints...>);
3078 //
3079 // int main()
3080 // {
3081 // // user_function's `T` will be deduced to `int` and `Ints...`
3082 // // will be deduced to `0, 1, 2, 3, 4`.
3083 // user_function(make_integer_sequence<int, 5>());
3084 // }
3085 template <typename T, T... Ints>
3087 {
3088  using value_type = T;
3089  static constexpr std::size_t size() noexcept
3090  {
3091  return sizeof...(Ints);
3092  }
3093 };
3094 
3095 // index_sequence
3096 //
3097 // A helper template for an `integer_sequence` of `size_t`,
3098 // `absl::index_sequence` is designed to be a drop-in replacement for C++14's
3099 // `std::index_sequence`.
3100 template <size_t... Ints>
3101 using index_sequence = integer_sequence<size_t, Ints...>;
3102 
3103 namespace utility_internal
3104 {
3105 
3106 template <typename Seq, size_t SeqSize, size_t Rem>
3107 struct Extend;
3108 
3109 // Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
3110 template <typename T, T... Ints, size_t SeqSize>
3111 struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
3112 {
3113  using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
3114 };
3115 
3116 template <typename T, T... Ints, size_t SeqSize>
3117 struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
3118 {
3119  using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
3120 };
3121 
3122 // Recursion helper for 'make_integer_sequence<T, N>'.
3123 // 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
3124 template <typename T, size_t N>
3125 struct Gen
3126 {
3127  using type =
3128  typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
3129 };
3130 
3131 template <typename T>
3132 struct Gen<T, 0>
3133 {
3135 };
3136 
3137 } // namespace utility_internal
3138 
3139 // Compile-time sequences of integers
3140 
3141 // make_integer_sequence
3142 //
3143 // This template alias is equivalent to
3144 // `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
3145 // replacement for C++14's `std::make_integer_sequence`.
3146 template <typename T, T N>
3148 
3149 // make_index_sequence
3150 //
3151 // This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`,
3152 // and is designed to be a drop-in replacement for C++14's
3153 // `std::make_index_sequence`.
3154 template <size_t N>
3156 
3157 // index_sequence_for
3158 //
3159 // Converts a typename pack into an index sequence of the same length, and
3160 // is designed to be a drop-in replacement for C++14's
3161 // `std::index_sequence_for()`
3162 template <typename... Ts>
3164 
3166 
3167 #endif
3168 
3169 // dispatch utility (taken from ranges-v3)
3170 template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
3171 template<> struct priority_tag<0> {};
3172 
3173 // taken from ranges-v3
3174 template<typename T>
3176 {
3177  static constexpr T value{};
3178 };
3179 
3180 template<typename T>
3181 constexpr T static_const<T>::value;
3182 
3183 } // namespace detail
3184 } // namespace nlohmann
3185 
3186 // #include <nlohmann/detail/meta/identity_tag.hpp>
3187 
3188 
3189 namespace nlohmann
3190 {
3191 namespace detail
3192 {
3193 // dispatching helper struct
3194 template <class T> struct identity_tag {};
3195 } // namespace detail
3196 } // namespace nlohmann
3197 
3198 // #include <nlohmann/detail/meta/type_traits.hpp>
3199 
3200 
3201 #include <limits> // numeric_limits
3202 #include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
3203 #include <utility> // declval
3204 #include <tuple> // tuple
3205 
3206 // #include <nlohmann/detail/iterators/iterator_traits.hpp>
3207 
3208 
3209 #include <iterator> // random_access_iterator_tag
3210 
3211 // #include <nlohmann/detail/meta/void_t.hpp>
3212 
3213 
3214 namespace nlohmann
3215 {
3216 namespace detail
3217 {
3218 template<typename ...Ts> struct make_void
3219 {
3220  using type = void;
3221 };
3222 template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
3223 } // namespace detail
3224 } // namespace nlohmann
3225 
3226 // #include <nlohmann/detail/meta/cpp_future.hpp>
3227 
3228 
3229 namespace nlohmann
3230 {
3231 namespace detail
3232 {
3233 template<typename It, typename = void>
3234 struct iterator_types {};
3235 
3236 template<typename It>
3238  It,
3239  void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
3240  typename It::reference, typename It::iterator_category >>
3241 {
3242  using difference_type = typename It::difference_type;
3243  using value_type = typename It::value_type;
3244  using pointer = typename It::pointer;
3245  using reference = typename It::reference;
3246  using iterator_category = typename It::iterator_category;
3247 };
3248 
3249 // This is required as some compilers implement std::iterator_traits in a way that
3250 // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
3251 template<typename T, typename = void>
3253 {
3254 };
3255 
3256 template<typename T>
3257 struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
3258  : iterator_types<T>
3259 {
3260 };
3261 
3262 template<typename T>
3264 {
3265  using iterator_category = std::random_access_iterator_tag;
3266  using value_type = T;
3267  using difference_type = ptrdiff_t;
3268  using pointer = T*;
3269  using reference = T&;
3270 };
3271 } // namespace detail
3272 } // namespace nlohmann
3273 
3274 // #include <nlohmann/detail/macro_scope.hpp>
3275 
3276 // #include <nlohmann/detail/meta/cpp_future.hpp>
3277 
3278 // #include <nlohmann/detail/meta/detected.hpp>
3279 
3280 
3281 #include <type_traits>
3282 
3283 // #include <nlohmann/detail/meta/void_t.hpp>
3284 
3285 
3286 // https://en.cppreference.com/w/cpp/experimental/is_detected
3287 namespace nlohmann
3288 {
3289 namespace detail
3290 {
3291 struct nonesuch
3292 {
3293  nonesuch() = delete;
3294  ~nonesuch() = delete;
3295  nonesuch(nonesuch const&) = delete;
3296  nonesuch(nonesuch const&&) = delete;
3297  void operator=(nonesuch const&) = delete;
3298  void operator=(nonesuch&&) = delete;
3299 };
3300 
3301 template<class Default,
3302  class AlwaysVoid,
3303  template<class...> class Op,
3304  class... Args>
3305 struct detector
3306 {
3307  using value_t = std::false_type;
3308  using type = Default;
3309 };
3310 
3311 template<class Default, template<class...> class Op, class... Args>
3312 struct detector<Default, void_t<Op<Args...>>, Op, Args...>
3313 {
3314  using value_t = std::true_type;
3315  using type = Op<Args...>;
3316 };
3317 
3318 template<template<class...> class Op, class... Args>
3319 using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
3320 
3321 template<template<class...> class Op, class... Args>
3322 struct is_detected_lazy : is_detected<Op, Args...> { };
3323 
3324 template<template<class...> class Op, class... Args>
3325 using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
3326 
3327 template<class Default, template<class...> class Op, class... Args>
3328 using detected_or = detector<Default, void, Op, Args...>;
3329 
3330 template<class Default, template<class...> class Op, class... Args>
3331 using detected_or_t = typename detected_or<Default, Op, Args...>::type;
3332 
3333 template<class Expected, template<class...> class Op, class... Args>
3334 using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
3335 
3336 template<class To, template<class...> class Op, class... Args>
3338  std::is_convertible<detected_t<Op, Args...>, To>;
3339 } // namespace detail
3340 } // namespace nlohmann
3341 
3342 // #include <nlohmann/json_fwd.hpp>
3343 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3344 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3345 
3346 #include <cstdint> // int64_t, uint64_t
3347 #include <map> // map
3348 #include <memory> // allocator
3349 #include <string> // string
3350 #include <vector> // vector
3351 
3357 namespace nlohmann
3358 {
3366 template<typename T = void, typename SFINAE = void>
3368 
3369 template<template<typename U, typename V, typename... Args> class ObjectType =
3370  std::map,
3371  template<typename U, typename... Args> class ArrayType = std::vector,
3372  class StringType = std::string, class BooleanType = bool,
3373  class NumberIntegerType = std::int64_t,
3374  class NumberUnsignedType = std::uint64_t,
3375  class NumberFloatType = double,
3376  template<typename U> class AllocatorType = std::allocator,
3377  template<typename T, typename SFINAE = void> class JSONSerializer =
3379  class BinaryType = std::vector<std::uint8_t>>
3381 
3393 template<typename BasicJsonType>
3395 
3405 
3406 template<class Key, class T, class IgnoredLess, class Allocator>
3408 
3417 
3418 } // namespace nlohmann
3419 
3420 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3421 
3422 
3423 namespace nlohmann
3424 {
3433 namespace detail
3434 {
3436 // helpers //
3438 
3439 // Note to maintainers:
3440 //
3441 // Every trait in this file expects a non CV-qualified type.
3442 // The only exceptions are in the 'aliases for detected' section
3443 // (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
3444 //
3445 // In this case, T has to be properly CV-qualified to constraint the function arguments
3446 // (e.g. to_json(BasicJsonType&, const T&))
3447 
3448 template<typename> struct is_basic_json : std::false_type {};
3449 
3451 struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
3452 
3454 // json_ref helpers //
3456 
3457 template<typename>
3458 class json_ref;
3459 
3460 template<typename>
3461 struct is_json_ref : std::false_type {};
3462 
3463 template<typename T>
3464 struct is_json_ref<json_ref<T>> : std::true_type {};
3465 
3467 // aliases for detected //
3469 
3470 template<typename T>
3471 using mapped_type_t = typename T::mapped_type;
3472 
3473 template<typename T>
3474 using key_type_t = typename T::key_type;
3475 
3476 template<typename T>
3477 using value_type_t = typename T::value_type;
3478 
3479 template<typename T>
3480 using difference_type_t = typename T::difference_type;
3481 
3482 template<typename T>
3483 using pointer_t = typename T::pointer;
3484 
3485 template<typename T>
3486 using reference_t = typename T::reference;
3487 
3488 template<typename T>
3489 using iterator_category_t = typename T::iterator_category;
3490 
3491 template<typename T>
3492 using iterator_t = typename T::iterator;
3493 
3494 template<typename T, typename... Args>
3495 using to_json_function = decltype(T::to_json(std::declval<Args>()...));
3496 
3497 template<typename T, typename... Args>
3498 using from_json_function = decltype(T::from_json(std::declval<Args>()...));
3499 
3500 template<typename T, typename U>
3501 using get_template_function = decltype(std::declval<T>().template get<U>());
3502 
3503 // trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
3504 template<typename BasicJsonType, typename T, typename = void>
3505 struct has_from_json : std::false_type {};
3506 
3507 // trait checking if j.get<T> is valid
3508 // use this trait instead of std::is_constructible or std::is_convertible,
3509 // both rely on, or make use of implicit conversions, and thus fail when T
3510 // has several constructors/operator= (see https://github.com/nlohmann/json/issues/958)
3511 template <typename BasicJsonType, typename T>
3513 {
3515 };
3516 
3517 template<typename BasicJsonType, typename T>
3518 struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3519 {
3520  using serializer = typename BasicJsonType::template json_serializer<T, void>;
3521 
3522  static constexpr bool value =
3524  const BasicJsonType&, T&>::value;
3525 };
3526 
3527 // This trait checks if JSONSerializer<T>::from_json(json const&) exists
3528 // this overload is used for non-default-constructible user-defined-types
3529 template<typename BasicJsonType, typename T, typename = void>
3530 struct has_non_default_from_json : std::false_type {};
3531 
3532 template<typename BasicJsonType, typename T>
3533 struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3534 {
3535  using serializer = typename BasicJsonType::template json_serializer<T, void>;
3536 
3537  static constexpr bool value =
3539  const BasicJsonType&>::value;
3540 };
3541 
3542 // This trait checks if BasicJsonType::json_serializer<T>::to_json exists
3543 // Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
3544 template<typename BasicJsonType, typename T, typename = void>
3545 struct has_to_json : std::false_type {};
3546 
3547 template<typename BasicJsonType, typename T>
3548 struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3549 {
3550  using serializer = typename BasicJsonType::template json_serializer<T, void>;
3551 
3552  static constexpr bool value =
3554  T>::value;
3555 };
3556 
3557 
3559 // is_ functions //
3561 
3562 // https://en.cppreference.com/w/cpp/types/conjunction
3563 template<class...> struct conjunction : std::true_type { };
3564 template<class B1> struct conjunction<B1> : B1 { };
3565 template<class B1, class... Bn>
3566 struct conjunction<B1, Bn...>
3567 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3568 
3569 // https://en.cppreference.com/w/cpp/types/negation
3570 template<class B> struct negation : std::integral_constant < bool, !B::value > { };
3571 
3572 // Reimplementation of is_constructible and is_default_constructible, due to them being broken for
3573 // std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
3574 // This causes compile errors in e.g. clang 3.5 or gcc 4.9.
3575 template <typename T>
3576 struct is_default_constructible : std::is_default_constructible<T> {};
3577 
3578 template <typename T1, typename T2>
3579 struct is_default_constructible<std::pair<T1, T2>>
3580  : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3581 
3582 template <typename T1, typename T2>
3583 struct is_default_constructible<const std::pair<T1, T2>>
3584  : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3585 
3586 template <typename... Ts>
3587 struct is_default_constructible<std::tuple<Ts...>>
3588  : conjunction<is_default_constructible<Ts>...> {};
3589 
3590 template <typename... Ts>
3591 struct is_default_constructible<const std::tuple<Ts...>>
3592  : conjunction<is_default_constructible<Ts>...> {};
3593 
3594 
3595 template <typename T, typename... Args>
3596 struct is_constructible : std::is_constructible<T, Args...> {};
3597 
3598 template <typename T1, typename T2>
3599 struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
3600 
3601 template <typename T1, typename T2>
3602 struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
3603 
3604 template <typename... Ts>
3605 struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
3606 
3607 template <typename... Ts>
3608 struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
3609 
3610 
3611 template<typename T, typename = void>
3612 struct is_iterator_traits : std::false_type {};
3613 
3614 template<typename T>
3616 {
3617  private:
3619 
3620  public:
3621  static constexpr auto value =
3627 };
3628 
3629 // The following implementation of is_complete_type is taken from
3630 // https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
3631 // and is written by Xiang Fan who agreed to using it in this library.
3632 
3633 template<typename T, typename = void>
3634 struct is_complete_type : std::false_type {};
3635 
3636 template<typename T>
3637 struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
3638 
3639 template<typename BasicJsonType, typename CompatibleObjectType,
3640  typename = void>
3641 struct is_compatible_object_type_impl : std::false_type {};
3642 
3643 template<typename BasicJsonType, typename CompatibleObjectType>
3645  BasicJsonType, CompatibleObjectType,
3646  enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
3647  is_detected<key_type_t, CompatibleObjectType>::value >>
3648 {
3649  using object_t = typename BasicJsonType::object_t;
3650 
3651  // macOS's is_constructible does not play well with nonesuch...
3652  static constexpr bool value =
3653  is_constructible<typename object_t::key_type,
3654  typename CompatibleObjectType::key_type>::value &&
3655  is_constructible<typename object_t::mapped_type,
3656  typename CompatibleObjectType::mapped_type>::value;
3657 };
3658 
3659 template<typename BasicJsonType, typename CompatibleObjectType>
3661  : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
3662 
3663 template<typename BasicJsonType, typename ConstructibleObjectType,
3664  typename = void>
3665 struct is_constructible_object_type_impl : std::false_type {};
3666 
3667 template<typename BasicJsonType, typename ConstructibleObjectType>
3669  BasicJsonType, ConstructibleObjectType,
3670  enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&&
3671  is_detected<key_type_t, ConstructibleObjectType>::value >>
3672 {
3673  using object_t = typename BasicJsonType::object_t;
3674 
3675  static constexpr bool value =
3679  (is_constructible<typename ConstructibleObjectType::key_type,
3680  typename object_t::key_type>::value &&
3681  std::is_same <
3682  typename object_t::mapped_type,
3683  typename ConstructibleObjectType::mapped_type >::value)) ||
3684  (has_from_json<BasicJsonType,
3685  typename ConstructibleObjectType::mapped_type>::value ||
3687  BasicJsonType,
3688  typename ConstructibleObjectType::mapped_type >::value);
3689 };
3690 
3691 template<typename BasicJsonType, typename ConstructibleObjectType>
3693  : is_constructible_object_type_impl<BasicJsonType,
3694  ConstructibleObjectType> {};
3695 
3696 template<typename BasicJsonType, typename CompatibleStringType,
3697  typename = void>
3698 struct is_compatible_string_type_impl : std::false_type {};
3699 
3700 template<typename BasicJsonType, typename CompatibleStringType>
3702  BasicJsonType, CompatibleStringType,
3703  enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3704  value_type_t, CompatibleStringType>::value >>
3705 {
3706  static constexpr auto value =
3708 };
3709 
3710 template<typename BasicJsonType, typename ConstructibleStringType>
3712  : is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
3713 
3714 template<typename BasicJsonType, typename ConstructibleStringType,
3715  typename = void>
3716 struct is_constructible_string_type_impl : std::false_type {};
3717 
3718 template<typename BasicJsonType, typename ConstructibleStringType>
3720  BasicJsonType, ConstructibleStringType,
3721  enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3722  value_type_t, ConstructibleStringType>::value >>
3723 {
3724  static constexpr auto value =
3725  is_constructible<ConstructibleStringType,
3726  typename BasicJsonType::string_t>::value;
3727 };
3728 
3729 template<typename BasicJsonType, typename ConstructibleStringType>
3731  : is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
3732 
3733 template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
3734 struct is_compatible_array_type_impl : std::false_type {};
3735 
3736 template<typename BasicJsonType, typename CompatibleArrayType>
3738  BasicJsonType, CompatibleArrayType,
3739  enable_if_t < is_detected<value_type_t, CompatibleArrayType>::value&&
3740  is_detected<iterator_t, CompatibleArrayType>::value&&
3741 // This is needed because json_reverse_iterator has a ::iterator type...
3742 // Therefore it is detected as a CompatibleArrayType.
3743 // The real fix would be to have an Iterable concept.
3745  iterator_traits<CompatibleArrayType >>::value >>
3746 {
3747  static constexpr bool value =
3748  is_constructible<BasicJsonType,
3749  typename CompatibleArrayType::value_type>::value;
3750 };
3751 
3752 template<typename BasicJsonType, typename CompatibleArrayType>
3754  : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
3755 
3756 template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
3757 struct is_constructible_array_type_impl : std::false_type {};
3758 
3759 template<typename BasicJsonType, typename ConstructibleArrayType>
3761  BasicJsonType, ConstructibleArrayType,
3762  enable_if_t<std::is_same<ConstructibleArrayType,
3763  typename BasicJsonType::value_type>::value >>
3764  : std::true_type {};
3765 
3766 template<typename BasicJsonType, typename ConstructibleArrayType>
3768  BasicJsonType, ConstructibleArrayType,
3769  enable_if_t < !std::is_same<ConstructibleArrayType,
3770  typename BasicJsonType::value_type>::value&&
3771  is_default_constructible<ConstructibleArrayType>::value&&
3772 (std::is_move_assignable<ConstructibleArrayType>::value ||
3773  std::is_copy_assignable<ConstructibleArrayType>::value)&&
3774 is_detected<value_type_t, ConstructibleArrayType>::value&&
3775 is_detected<iterator_t, ConstructibleArrayType>::value&&
3777 detected_t<value_type_t, ConstructibleArrayType >>::value >>
3778 {
3779  static constexpr bool value =
3780  // This is needed because json_reverse_iterator has a ::iterator type,
3781  // furthermore, std::back_insert_iterator (and other iterators) have a
3782  // base class `iterator`... Therefore it is detected as a
3783  // ConstructibleArrayType. The real fix would be to have an Iterable
3784  // concept.
3786 
3787  (std::is_same<typename ConstructibleArrayType::value_type,
3788  typename BasicJsonType::array_t::value_type>::value ||
3789  has_from_json<BasicJsonType,
3790  typename ConstructibleArrayType::value_type>::value ||
3792  BasicJsonType, typename ConstructibleArrayType::value_type >::value);
3793 };
3794 
3795 template<typename BasicJsonType, typename ConstructibleArrayType>
3797  : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
3798 
3799 template<typename RealIntegerType, typename CompatibleNumberIntegerType,
3800  typename = void>
3801 struct is_compatible_integer_type_impl : std::false_type {};
3802 
3803 template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3805  RealIntegerType, CompatibleNumberIntegerType,
3806  enable_if_t < std::is_integral<RealIntegerType>::value&&
3807  std::is_integral<CompatibleNumberIntegerType>::value&&
3808  !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3809 {
3810  // is there an assert somewhere on overflows?
3811  using RealLimits = std::numeric_limits<RealIntegerType>;
3812  using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
3813 
3814  static constexpr auto value =
3815  is_constructible<RealIntegerType,
3816  CompatibleNumberIntegerType>::value &&
3817  CompatibleLimits::is_integer &&
3818  RealLimits::is_signed == CompatibleLimits::is_signed;
3819 };
3820 
3821 template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3823  : is_compatible_integer_type_impl<RealIntegerType,
3824  CompatibleNumberIntegerType> {};
3825 
3826 template<typename BasicJsonType, typename CompatibleType, typename = void>
3827 struct is_compatible_type_impl: std::false_type {};
3828 
3829 template<typename BasicJsonType, typename CompatibleType>
3831  BasicJsonType, CompatibleType,
3832  enable_if_t<is_complete_type<CompatibleType>::value >>
3833 {
3834  static constexpr bool value =
3836 };
3837 
3838 template<typename BasicJsonType, typename CompatibleType>
3840  : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
3841 
3842 template<typename T1, typename T2>
3843 struct is_constructible_tuple : std::false_type {};
3844 
3845 template<typename T1, typename... Args>
3846 struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
3847 
3848 // to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
3851 {
3852  return static_cast<T>(value);
3853 }
3854 
3856 T conditional_static_cast(U value)
3857 {
3858  return value;
3859 }
3860 
3861 } // namespace detail
3862 } // namespace nlohmann
3863 
3864 // #include <nlohmann/detail/value_t.hpp>
3865 
3866 
3867 namespace nlohmann
3868 {
3869 namespace detail
3870 {
3871 template<typename BasicJsonType>
3872 void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
3873 {
3874  if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
3875  {
3876  JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j));
3877  }
3878  n = nullptr;
3879 }
3880 
3881 // overloads for basic_json template parameters
3882 template < typename BasicJsonType, typename ArithmeticType,
3885  int > = 0 >
3886 void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
3887 {
3888  switch (static_cast<value_t>(j))
3889  {
3891  {
3892  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3893  break;
3894  }
3896  {
3897  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3898  break;
3899  }
3900  case value_t::number_float:
3901  {
3902  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3903  break;
3904  }
3905 
3906  case value_t::null:
3907  case value_t::object:
3908  case value_t::array:
3909  case value_t::string:
3910  case value_t::boolean:
3911  case value_t::binary:
3912  case value_t::discarded:
3913  default:
3914  JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
3915  }
3916 }
3917 
3918 template<typename BasicJsonType>
3919 void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
3920 {
3921  if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
3922  {
3923  JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j));
3924  }
3925  b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3926 }
3927 
3928 template<typename BasicJsonType>
3929 void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
3930 {
3931  if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3932  {
3933  JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
3934  }
3935  s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3936 }
3937 
3938 template <
3939  typename BasicJsonType, typename ConstructibleStringType,
3940  enable_if_t <
3942  !std::is_same<typename BasicJsonType::string_t,
3943  ConstructibleStringType>::value,
3944  int > = 0 >
3945 void from_json(const BasicJsonType& j, ConstructibleStringType& s)
3946 {
3947  if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3948  {
3949  JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
3950  }
3951 
3952  s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3953 }
3954 
3955 template<typename BasicJsonType>
3956 void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
3957 {
3958  get_arithmetic_value(j, val);
3959 }
3960 
3961 template<typename BasicJsonType>
3962 void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
3963 {
3964  get_arithmetic_value(j, val);
3965 }
3966 
3967 template<typename BasicJsonType>
3968 void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
3969 {
3970  get_arithmetic_value(j, val);
3971 }
3972 
3973 template<typename BasicJsonType, typename EnumType,
3975 void from_json(const BasicJsonType& j, EnumType& e)
3976 {
3978  get_arithmetic_value(j, val);
3979  e = static_cast<EnumType>(val);
3980 }
3981 
3982 // forward_list doesn't have an insert method
3983 template<typename BasicJsonType, typename T, typename Allocator,
3985 void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3986 {
3987  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3988  {
3989  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
3990  }
3991  l.clear();
3992  std::transform(j.rbegin(), j.rend(),
3993  std::front_inserter(l), [](const BasicJsonType & i)
3994  {
3995  return i.template get<T>();
3996  });
3997 }
3998 
3999 // valarray doesn't have an insert method
4000 template<typename BasicJsonType, typename T,
4002 void from_json(const BasicJsonType& j, std::valarray<T>& l)
4003 {
4004  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4005  {
4006  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4007  }
4008  l.resize(j.size());
4009  std::transform(j.begin(), j.end(), std::begin(l),
4010  [](const BasicJsonType & elem)
4011  {
4012  return elem.template get<T>();
4013  });
4014 }
4015 
4016 template<typename BasicJsonType, typename T, std::size_t N>
4017 auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4018 -> decltype(j.template get<T>(), void())
4019 {
4020  for (std::size_t i = 0; i < N; ++i)
4021  {
4022  arr[i] = j.at(i).template get<T>();
4023  }
4024 }
4025 
4026 template<typename BasicJsonType>
4027 void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
4028 {
4029  arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4030 }
4031 
4032 template<typename BasicJsonType, typename T, std::size_t N>
4033 auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
4034  priority_tag<2> /*unused*/)
4035 -> decltype(j.template get<T>(), void())
4036 {
4037  for (std::size_t i = 0; i < N; ++i)
4038  {
4039  arr[i] = j.at(i).template get<T>();
4040  }
4041 }
4042 
4043 template<typename BasicJsonType, typename ConstructibleArrayType,
4044  enable_if_t<
4046  int> = 0>
4047 auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
4048 -> decltype(
4049  arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4050  j.template get<typename ConstructibleArrayType::value_type>(),
4051  void())
4052 {
4053  using std::end;
4054 
4055  ConstructibleArrayType ret;
4056  ret.reserve(j.size());
4057  std::transform(j.begin(), j.end(),
4058  std::inserter(ret, end(ret)), [](const BasicJsonType & i)
4059  {
4060  // get<BasicJsonType>() returns *this, this won't call a from_json
4061  // method when value_type is BasicJsonType
4062  return i.template get<typename ConstructibleArrayType::value_type>();
4063  });
4064  arr = std::move(ret);
4065 }
4066 
4067 template<typename BasicJsonType, typename ConstructibleArrayType,
4068  enable_if_t<
4070  int> = 0>
4071 void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
4072  priority_tag<0> /*unused*/)
4073 {
4074  using std::end;
4075 
4076  ConstructibleArrayType ret;
4077  std::transform(
4078  j.begin(), j.end(), std::inserter(ret, end(ret)),
4079  [](const BasicJsonType & i)
4080  {
4081  // get<BasicJsonType>() returns *this, this won't call a from_json
4082  // method when value_type is BasicJsonType
4083  return i.template get<typename ConstructibleArrayType::value_type>();
4084  });
4085  arr = std::move(ret);
4086 }
4087 
4088 template < typename BasicJsonType, typename ConstructibleArrayType,
4089  enable_if_t <
4095  int > = 0 >
4096 auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
4097 -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4098 j.template get<typename ConstructibleArrayType::value_type>(),
4099 void())
4100 {
4101  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4102  {
4103  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4104  }
4105 
4107 }
4108 
4109 template < typename BasicJsonType, typename T, std::size_t... Idx >
4110 std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4111  identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
4112 {
4113  return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4114 }
4115 
4116 template < typename BasicJsonType, typename T, std::size_t N >
4117 auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4118 -> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4119 {
4120  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4121  {
4122  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4123  }
4124 
4125  return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4126 }
4127 
4128 template<typename BasicJsonType>
4129 void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
4130 {
4131  if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
4132  {
4133  JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j));
4134  }
4135 
4136  bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4137 }
4138 
4139 template<typename BasicJsonType, typename ConstructibleObjectType,
4141 void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
4142 {
4143  if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
4144  {
4145  JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j));
4146  }
4147 
4148  ConstructibleObjectType ret;
4149  const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4150  using value_type = typename ConstructibleObjectType::value_type;
4151  std::transform(
4152  inner_object->begin(), inner_object->end(),
4153  std::inserter(ret, ret.begin()),
4154  [](typename BasicJsonType::object_t::value_type const & p)
4155  {
4156  return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4157  });
4158  obj = std::move(ret);
4159 }
4160 
4161 // overload for arithmetic types, not chosen for basic_json template arguments
4162 // (BooleanType, etc..); note: Is it really necessary to provide explicit
4163 // overloads for boolean_t etc. in case of a custom BooleanType which is not
4164 // an arithmetic type?
4165 template < typename BasicJsonType, typename ArithmeticType,
4166  enable_if_t <
4172  int > = 0 >
4173 void from_json(const BasicJsonType& j, ArithmeticType& val)
4174 {
4175  switch (static_cast<value_t>(j))
4176  {
4178  {
4179  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4180  break;
4181  }
4183  {
4184  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4185  break;
4186  }
4187  case value_t::number_float:
4188  {
4189  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4190  break;
4191  }
4192  case value_t::boolean:
4193  {
4194  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4195  break;
4196  }
4197 
4198  case value_t::null:
4199  case value_t::object:
4200  case value_t::array:
4201  case value_t::string:
4202  case value_t::binary:
4203  case value_t::discarded:
4204  default:
4205  JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
4206  }
4207 }
4208 
4209 template<typename BasicJsonType, typename... Args, std::size_t... Idx>
4210 std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
4211 {
4212  return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
4213 }
4214 
4215 template < typename BasicJsonType, class A1, class A2 >
4216 std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
4217 {
4218  return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4219  std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4220 }
4221 
4222 template<typename BasicJsonType, typename A1, typename A2>
4223 void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
4224 {
4225  p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4226 }
4227 
4228 template<typename BasicJsonType, typename... Args>
4229 std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
4230 {
4231  return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4232 }
4233 
4234 template<typename BasicJsonType, typename... Args>
4235 void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
4236 {
4237  t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4238 }
4239 
4240 template<typename BasicJsonType, typename TupleRelated>
4241 auto from_json(BasicJsonType&& j, TupleRelated&& t)
4242 -> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4243 {
4244  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4245  {
4246  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4247  }
4248 
4249  return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4250 }
4251 
4252 template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
4253  typename = enable_if_t < !std::is_constructible <
4254  typename BasicJsonType::string_t, Key >::value >>
4255 void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4256 {
4257  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4258  {
4259  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4260  }
4261  m.clear();
4262  for (const auto& p : j)
4263  {
4264  if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4265  {
4266  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4267  }
4268  m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4269  }
4270 }
4271 
4272 template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
4273  typename = enable_if_t < !std::is_constructible <
4274  typename BasicJsonType::string_t, Key >::value >>
4275 void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4276 {
4277  if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4278  {
4279  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4280  }
4281  m.clear();
4282  for (const auto& p : j)
4283  {
4284  if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4285  {
4286  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4287  }
4288  m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4289  }
4290 }
4291 
4293 {
4294  template<typename BasicJsonType, typename T>
4295  auto operator()(const BasicJsonType& j, T&& val) const
4296  noexcept(noexcept(from_json(j, std::forward<T>(val))))
4297  -> decltype(from_json(j, std::forward<T>(val)))
4298  {
4299  return from_json(j, std::forward<T>(val));
4300  }
4301 };
4302 } // namespace detail
4303 
4307 namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
4308 {
4309 constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
4310 } // namespace
4311 } // namespace nlohmann
4312 
4313 // #include <nlohmann/detail/conversions/to_json.hpp>
4314 
4315 
4316 #include <algorithm> // copy
4317 #include <iterator> // begin, end
4318 #include <string> // string
4319 #include <tuple> // tuple, get
4320 #include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
4321 #include <utility> // move, forward, declval, pair
4322 #include <valarray> // valarray
4323 #include <vector> // vector
4324 
4325 // #include <nlohmann/detail/iterators/iteration_proxy.hpp>
4326 
4327 
4328 #include <cstddef> // size_t
4329 #include <iterator> // input_iterator_tag
4330 #include <string> // string, to_string
4331 #include <tuple> // tuple_size, get, tuple_element
4332 #include <utility> // move
4333 
4334 // #include <nlohmann/detail/meta/type_traits.hpp>
4335 
4336 // #include <nlohmann/detail/value_t.hpp>
4337 
4338 
4339 namespace nlohmann
4340 {
4341 namespace detail
4342 {
4343 template<typename string_type>
4344 void int_to_string( string_type& target, std::size_t value )
4345 {
4346  // For ADL
4347  using std::to_string;
4348  target = to_string(value);
4349 }
4350 template<typename IteratorType> class iteration_proxy_value
4351 {
4352  public:
4353  using difference_type = std::ptrdiff_t;
4355  using pointer = value_type * ;
4356  using reference = value_type & ;
4357  using iterator_category = std::input_iterator_tag;
4358  using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
4359 
4360  private:
4362  IteratorType anchor;
4364  std::size_t array_index = 0;
4366  mutable std::size_t array_index_last = 0;
4371 
4372  public:
4373  explicit iteration_proxy_value(IteratorType it) noexcept
4374  : anchor(std::move(it))
4375  {}
4376 
4379  {
4380  return *this;
4381  }
4382 
4385  {
4386  ++anchor;
4387  ++array_index;
4388 
4389  return *this;
4390  }
4391 
4394  {
4395  return anchor == o.anchor;
4396  }
4397 
4400  {
4401  return anchor != o.anchor;
4402  }
4403 
4405  const string_type& key() const
4406  {
4407  JSON_ASSERT(anchor.m_object != nullptr);
4408 
4409  switch (anchor.m_object->type())
4410  {
4411  // use integer array index as key
4412  case value_t::array:
4413  {
4415  {
4418  }
4419  return array_index_str;
4420  }
4421 
4422  // use key from the object
4423  case value_t::object:
4424  return anchor.key();
4425 
4426  // use an empty key for all primitive types
4427  case value_t::null:
4428  case value_t::string:
4429  case value_t::boolean:
4432  case value_t::number_float:
4433  case value_t::binary:
4434  case value_t::discarded:
4435  default:
4436  return empty_str;
4437  }
4438  }
4439 
4441  typename IteratorType::reference value() const
4442  {
4443  return anchor.value();
4444  }
4445 };
4446 
4448 template<typename IteratorType> class iteration_proxy
4449 {
4450  private:
4452  typename IteratorType::reference container;
4453 
4454  public:
4456  explicit iteration_proxy(typename IteratorType::reference cont) noexcept
4457  : container(cont) {}
4458 
4461  {
4463  }
4464 
4467  {
4469  }
4470 };
4471 // Structured Bindings Support
4472 // For further reference see https://blog.tartanllama.xyz/structured-bindings/
4473 // And see https://github.com/nlohmann/json/pull/1391
4474 template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
4476 {
4477  return i.key();
4478 }
4479 // Structured Bindings Support
4480 // For further reference see https://blog.tartanllama.xyz/structured-bindings/
4481 // And see https://github.com/nlohmann/json/pull/1391
4482 template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
4483 auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
4484 {
4485  return i.value();
4486 }
4487 } // namespace detail
4488 } // namespace nlohmann
4489 
4490 // The Addition to the STD Namespace is required to add
4491 // Structured Bindings Support to the iteration_proxy_value class
4492 // For further reference see https://blog.tartanllama.xyz/structured-bindings/
4493 // And see https://github.com/nlohmann/json/pull/1391
4494 namespace std
4495 {
4496 #if defined(__clang__)
4497  // Fix: https://github.com/nlohmann/json/issues/1401
4498  #pragma clang diagnostic push
4499  #pragma clang diagnostic ignored "-Wmismatched-tags"
4500 #endif
4501 template<typename IteratorType>
4502 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
4503  : public std::integral_constant<std::size_t, 2> {};
4504 
4505 template<std::size_t N, typename IteratorType>
4506 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
4507 {
4508  public:
4509  using type = decltype(
4510  get<N>(std::declval <
4512 };
4513 #if defined(__clang__)
4514  #pragma clang diagnostic pop
4515 #endif
4516 } // namespace std
4517 
4518 // #include <nlohmann/detail/meta/cpp_future.hpp>
4519 
4520 // #include <nlohmann/detail/meta/type_traits.hpp>
4521 
4522 // #include <nlohmann/detail/value_t.hpp>
4523 
4524 
4525 namespace nlohmann
4526 {
4527 namespace detail
4528 {
4530 // constructors //
4532 
4533 /*
4534  * Note all external_constructor<>::construct functions need to call
4535  * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an
4536  * allocated value (e.g., a string). See bug issue
4537  * https://github.com/nlohmann/json/issues/2865 for more information.
4538  */
4539 
4540 template<value_t> struct external_constructor;
4541 
4542 template<>
4544 {
4545  template<typename BasicJsonType>
4546  static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
4547  {
4548  j.m_value.destroy(j.m_type);
4549  j.m_type = value_t::boolean;
4550  j.m_value = b;
4551  j.assert_invariant();
4552  }
4553 };
4554 
4555 template<>
4557 {
4558  template<typename BasicJsonType>
4559  static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
4560  {
4561  j.m_value.destroy(j.m_type);
4562  j.m_type = value_t::string;
4563  j.m_value = s;
4564  j.assert_invariant();
4565  }
4566 
4567  template<typename BasicJsonType>
4568  static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4569  {
4570  j.m_value.destroy(j.m_type);
4571  j.m_type = value_t::string;
4572  j.m_value = std::move(s);
4573  j.assert_invariant();
4574  }
4575 
4576  template < typename BasicJsonType, typename CompatibleStringType,
4578  int > = 0 >
4579  static void construct(BasicJsonType& j, const CompatibleStringType& str)
4580  {
4581  j.m_value.destroy(j.m_type);
4582  j.m_type = value_t::string;
4583  j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4584  j.assert_invariant();
4585  }
4586 };
4587 
4588 template<>
4590 {
4591  template<typename BasicJsonType>
4592  static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
4593  {
4594  j.m_value.destroy(j.m_type);
4595  j.m_type = value_t::binary;
4596  j.m_value = typename BasicJsonType::binary_t(b);
4597  j.assert_invariant();
4598  }
4599 
4600  template<typename BasicJsonType>
4601  static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
4602  {
4603  j.m_value.destroy(j.m_type);
4604  j.m_type = value_t::binary;
4605  j.m_value = typename BasicJsonType::binary_t(std::move(b));;
4606  j.assert_invariant();
4607  }
4608 };
4609 
4610 template<>
4612 {
4613  template<typename BasicJsonType>
4614  static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
4615  {
4616  j.m_value.destroy(j.m_type);
4617  j.m_type = value_t::number_float;
4618  j.m_value = val;
4619  j.assert_invariant();
4620  }
4621 };
4622 
4623 template<>
4625 {
4626  template<typename BasicJsonType>
4627  static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
4628  {
4629  j.m_value.destroy(j.m_type);
4630  j.m_type = value_t::number_unsigned;
4631  j.m_value = val;
4632  j.assert_invariant();
4633  }
4634 };
4635 
4636 template<>
4638 {
4639  template<typename BasicJsonType>
4640  static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
4641  {
4642  j.m_value.destroy(j.m_type);
4643  j.m_type = value_t::number_integer;
4644  j.m_value = val;
4645  j.assert_invariant();
4646  }
4647 };
4648 
4649 template<>
4651 {
4652  template<typename BasicJsonType>
4653  static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
4654  {
4655  j.m_value.destroy(j.m_type);
4656  j.m_type = value_t::array;
4657  j.m_value = arr;
4658  j.set_parents();
4659  j.assert_invariant();
4660  }
4661 
4662  template<typename BasicJsonType>
4663  static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4664  {
4665  j.m_value.destroy(j.m_type);
4666  j.m_type = value_t::array;
4667  j.m_value = std::move(arr);
4668  j.set_parents();
4669  j.assert_invariant();
4670  }
4671 
4672  template < typename BasicJsonType, typename CompatibleArrayType,
4674  int > = 0 >
4675  static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
4676  {
4677  using std::begin;
4678  using std::end;
4679 
4680  j.m_value.destroy(j.m_type);
4681  j.m_type = value_t::array;
4682  j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4683  j.set_parents();
4684  j.assert_invariant();
4685  }
4686 
4687  template<typename BasicJsonType>
4688  static void construct(BasicJsonType& j, const std::vector<bool>& arr)
4689  {
4690  j.m_value.destroy(j.m_type);
4691  j.m_type = value_t::array;
4692  j.m_value = value_t::array;
4693  j.m_value.array->reserve(arr.size());
4694  for (const bool x : arr)
4695  {
4696  j.m_value.array->push_back(x);
4697  j.set_parent(j.m_value.array->back());
4698  }
4699  j.assert_invariant();
4700  }
4701 
4702  template<typename BasicJsonType, typename T,
4704  static void construct(BasicJsonType& j, const std::valarray<T>& arr)
4705  {
4706  j.m_value.destroy(j.m_type);
4707  j.m_type = value_t::array;
4708  j.m_value = value_t::array;
4709  j.m_value.array->resize(arr.size());
4710  if (arr.size() > 0)
4711  {
4712  std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4713  }
4714  j.set_parents();
4715  j.assert_invariant();
4716  }
4717 };
4718 
4719 template<>
4721 {
4722  template<typename BasicJsonType>
4723  static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
4724  {
4725  j.m_value.destroy(j.m_type);
4726  j.m_type = value_t::object;
4727  j.m_value = obj;
4728  j.set_parents();
4729  j.assert_invariant();
4730  }
4731 
4732  template<typename BasicJsonType>
4733  static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4734  {
4735  j.m_value.destroy(j.m_type);
4736  j.m_type = value_t::object;
4737  j.m_value = std::move(obj);
4738  j.set_parents();
4739  j.assert_invariant();
4740  }
4741 
4742  template < typename BasicJsonType, typename CompatibleObjectType,
4744  static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
4745  {
4746  using std::begin;
4747  using std::end;
4748 
4749  j.m_value.destroy(j.m_type);
4750  j.m_type = value_t::object;
4751  j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4752  j.set_parents();
4753  j.assert_invariant();
4754  }
4755 };
4756 
4758 // to_json //
4760 
4761 template<typename BasicJsonType, typename T,
4763 void to_json(BasicJsonType& j, T b) noexcept
4764 {
4766 }
4767 
4768 template<typename BasicJsonType, typename CompatibleString,
4770 void to_json(BasicJsonType& j, const CompatibleString& s)
4771 {
4773 }
4774 
4775 template<typename BasicJsonType>
4776 void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4777 {
4779 }
4780 
4781 template<typename BasicJsonType, typename FloatType,
4783 void to_json(BasicJsonType& j, FloatType val) noexcept
4784 {
4785  external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
4786 }
4787 
4788 template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
4790 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4791 {
4792  external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
4793 }
4794 
4795 template<typename BasicJsonType, typename CompatibleNumberIntegerType,
4797 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4798 {
4799  external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
4800 }
4801 
4802 template<typename BasicJsonType, typename EnumType,
4804 void to_json(BasicJsonType& j, EnumType e) noexcept
4805 {
4806  using underlying_type = typename std::underlying_type<EnumType>::type;
4807  external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
4808 }
4809 
4810 template<typename BasicJsonType>
4811 void to_json(BasicJsonType& j, const std::vector<bool>& e)
4812 {
4814 }
4815 
4816 template < typename BasicJsonType, typename CompatibleArrayType,
4817  enable_if_t < is_compatible_array_type<BasicJsonType,
4818  CompatibleArrayType>::value&&
4823  int > = 0 >
4824 void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
4825 {
4827 }
4828 
4829 template<typename BasicJsonType>
4830 void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
4831 {
4833 }
4834 
4835 template<typename BasicJsonType, typename T,
4837 void to_json(BasicJsonType& j, const std::valarray<T>& arr)
4838 {
4840 }
4841 
4842 template<typename BasicJsonType>
4843 void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4844 {
4846 }
4847 
4848 template < typename BasicJsonType, typename CompatibleObjectType,
4850 void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
4851 {
4853 }
4854 
4855 template<typename BasicJsonType>
4856 void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4857 {
4859 }
4860 
4861 template <
4862  typename BasicJsonType, typename T, std::size_t N,
4863  enable_if_t < !std::is_constructible<typename BasicJsonType::string_t,
4864  const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4865  int > = 0 >
4866 void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4867 {
4869 }
4870 
4872 void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
4873 {
4874  j = { p.first, p.second };
4875 }
4876 
4877 // for https://github.com/nlohmann/json/pull/1134
4878 template<typename BasicJsonType, typename T,
4879  enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
4880 void to_json(BasicJsonType& j, const T& b)
4881 {
4882  j = { {b.key(), b.value()} };
4883 }
4884 
4885 template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
4886 void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
4887 {
4888  j = { std::get<Idx>(t)... };
4889 }
4890 
4892 void to_json(BasicJsonType& j, const T& t)
4893 {
4895 }
4896 
4898 {
4899  template<typename BasicJsonType, typename T>
4900  auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
4901  -> decltype(to_json(j, std::forward<T>(val)), void())
4902  {
4903  return to_json(j, std::forward<T>(val));
4904  }
4905 };
4906 } // namespace detail
4907 
4911 namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
4912 {
4913 constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
4914 } // namespace
4915 } // namespace nlohmann
4916 
4917 // #include <nlohmann/detail/meta/identity_tag.hpp>
4918 
4919 // #include <nlohmann/detail/meta/type_traits.hpp>
4920 
4921 
4922 namespace nlohmann
4923 {
4924 
4925 template<typename ValueType, typename>
4926 struct adl_serializer
4927 {
4939  template<typename BasicJsonType, typename TargetType = ValueType>
4940  static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
4941  noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
4942  -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
4943  {
4944  ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4945  }
4946 
4959  template<typename BasicJsonType, typename TargetType = ValueType>
4960  static auto from_json(BasicJsonType && j) noexcept(
4961  noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
4962  -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
4963  {
4964  return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
4965  }
4966 
4976  template<typename BasicJsonType, typename TargetType = ValueType>
4977  static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
4978  noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
4979  -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
4980  {
4981  ::nlohmann::to_json(j, std::forward<TargetType>(val));
4982  }
4983 };
4984 } // namespace nlohmann
4985 
4986 // #include <nlohmann/byte_container_with_subtype.hpp>
4987 
4988 
4989 #include <cstdint> // uint8_t, uint64_t
4990 #include <tuple> // tie
4991 #include <utility> // move
4992 
4993 namespace nlohmann
4994 {
4995 
5009 template<typename BinaryType>
5010 class byte_container_with_subtype : public BinaryType
5011 {
5012  public:
5014  using container_type = BinaryType;
5016  using subtype_type = std::uint64_t;
5017 
5019  : container_type()
5020  {}
5021 
5023  : container_type(b)
5024  {}
5025 
5026  byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
5027  : container_type(std::move(b))
5028  {}
5029 
5031  : container_type(b)
5032  , m_subtype(subtype_)
5033  , m_has_subtype(true)
5034  {}
5035 
5036  byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
5037  : container_type(std::move(b))
5038  , m_subtype(subtype_)
5039  , m_has_subtype(true)
5040  {}
5041 
5043  {
5044  return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
5045  std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5046  }
5047 
5049  {
5050  return !(rhs == *this);
5051  }
5052 
5071  void set_subtype(subtype_type subtype_) noexcept
5072  {
5073  m_subtype = subtype_;
5074  m_has_subtype = true;
5075  }
5076 
5099  constexpr subtype_type subtype() const noexcept
5100  {
5101  return m_has_subtype ? m_subtype : subtype_type(-1);
5102  }
5103 
5120  constexpr bool has_subtype() const noexcept
5121  {
5122  return m_has_subtype;
5123  }
5124 
5144  void clear_subtype() noexcept
5145  {
5146  m_subtype = 0;
5147  m_has_subtype = false;
5148  }
5149 
5150  private:
5152  bool m_has_subtype = false;
5153 };
5154 
5155 } // namespace nlohmann
5156 
5157 // #include <nlohmann/detail/conversions/from_json.hpp>
5158 
5159 // #include <nlohmann/detail/conversions/to_json.hpp>
5160 
5161 // #include <nlohmann/detail/exceptions.hpp>
5162 
5163 // #include <nlohmann/detail/hash.hpp>
5164 
5165 
5166 #include <cstdint> // uint8_t
5167 #include <cstddef> // size_t
5168 #include <functional> // hash
5169 
5170 // #include <nlohmann/detail/macro_scope.hpp>
5171 
5172 
5173 namespace nlohmann
5174 {
5175 namespace detail
5176 {
5177 
5178 // boost::hash_combine
5179 inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
5180 {
5181  seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5182  return seed;
5183 }
5184 
5196 template<typename BasicJsonType>
5197 std::size_t hash(const BasicJsonType& j)
5198 {
5199  using string_t = typename BasicJsonType::string_t;
5200  using number_integer_t = typename BasicJsonType::number_integer_t;
5201  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5202  using number_float_t = typename BasicJsonType::number_float_t;
5203 
5204  const auto type = static_cast<std::size_t>(j.type());
5205  switch (j.type())
5206  {
5207  case BasicJsonType::value_t::null:
5208  case BasicJsonType::value_t::discarded:
5209  {
5210  return combine(type, 0);
5211  }
5212 
5214  {
5215  auto seed = combine(type, j.size());
5216  for (const auto& element : j.items())
5217  {
5218  const auto h = std::hash<string_t> {}(element.key());
5219  seed = combine(seed, h);
5220  seed = combine(seed, hash(element.value()));
5221  }
5222  return seed;
5223  }
5224 
5225  case BasicJsonType::value_t::array:
5226  {
5227  auto seed = combine(type, j.size());
5228  for (const auto& element : j)
5229  {
5230  seed = combine(seed, hash(element));
5231  }
5232  return seed;
5233  }
5234 
5235  case BasicJsonType::value_t::string:
5236  {
5237  const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5238  return combine(type, h);
5239  }
5240 
5241  case BasicJsonType::value_t::boolean:
5242  {
5243  const auto h = std::hash<bool> {}(j.template get<bool>());
5244  return combine(type, h);
5245  }
5246 
5247  case BasicJsonType::value_t::number_integer:
5248  {
5249  const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5250  return combine(type, h);
5251  }
5252 
5253  case BasicJsonType::value_t::number_unsigned:
5254  {
5255  const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5256  return combine(type, h);
5257  }
5258 
5259  case BasicJsonType::value_t::number_float:
5260  {
5261  const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5262  return combine(type, h);
5263  }
5264 
5265  case BasicJsonType::value_t::binary:
5266  {
5267  auto seed = combine(type, j.get_binary().size());
5268  const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5269  seed = combine(seed, h);
5270  seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
5271  for (const auto byte : j.get_binary())
5272  {
5273  seed = combine(seed, std::hash<std::uint8_t> {}(byte));
5274  }
5275  return seed;
5276  }
5277 
5278  default: // LCOV_EXCL_LINE
5279  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
5280  return 0; // LCOV_EXCL_LINE
5281  }
5282 }
5283 
5284 } // namespace detail
5285 } // namespace nlohmann
5286 
5287 // #include <nlohmann/detail/input/binary_reader.hpp>
5288 
5289 
5290 #include <algorithm> // generate_n
5291 #include <array> // array
5292 #include <cmath> // ldexp
5293 #include <cstddef> // size_t
5294 #include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
5295 #include <cstdio> // snprintf
5296 #include <cstring> // memcpy
5297 #include <iterator> // back_inserter
5298 #include <limits> // numeric_limits
5299 #include <string> // char_traits, string
5300 #include <utility> // make_pair, move
5301 #include <vector> // vector
5302 
5303 // #include <nlohmann/detail/exceptions.hpp>
5304 
5305 // #include <nlohmann/detail/input/input_adapters.hpp>
5306 
5307 
5308 #include <array> // array
5309 #include <cstddef> // size_t
5310 #include <cstring> // strlen
5311 #include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
5312 #include <memory> // shared_ptr, make_shared, addressof
5313 #include <numeric> // accumulate
5314 #include <string> // string, char_traits
5315 #include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
5316 #include <utility> // pair, declval
5317 
5318 #ifndef JSON_NO_IO
5319  #include <cstdio> // FILE *
5320  #include <istream> // istream
5321 #endif // JSON_NO_IO
5322 
5323 // #include <nlohmann/detail/iterators/iterator_traits.hpp>
5324 
5325 // #include <nlohmann/detail/macro_scope.hpp>
5326 
5327 
5328 namespace nlohmann
5329 {
5330 namespace detail
5331 {
5334 
5336 // input adapters //
5338 
5339 #ifndef JSON_NO_IO
5340 
5345 {
5346  public:
5347  using char_type = char;
5348 
5350  explicit file_input_adapter(std::FILE* f) noexcept
5351  : m_file(f)
5352  {}
5353 
5354  // make class move-only
5355  file_input_adapter(const file_input_adapter&) = delete;
5357  file_input_adapter& operator=(const file_input_adapter&) = delete;
5358  file_input_adapter& operator=(file_input_adapter&&) = delete;
5360 
5361  std::char_traits<char>::int_type get_character() noexcept
5362  {
5363  return std::fgetc(m_file);
5364  }
5365 
5366  private:
5368  std::FILE* m_file;
5369 };
5370 
5371 
5382 {
5383  public:
5384  using char_type = char;
5385 
5387  {
5388  // clear stream flags; we use underlying streambuf I/O, do not
5389  // maintain ifstream flags, except eof
5390  if (is != nullptr)
5391  {
5392  is->clear(is->rdstate() & std::ios::eofbit);
5393  }
5394  }
5395 
5396  explicit input_stream_adapter(std::istream& i)
5397  : is(&i), sb(i.rdbuf())
5398  {}
5399 
5400  // delete because of pointer members
5401  input_stream_adapter(const input_stream_adapter&) = delete;
5404 
5406  : is(rhs.is), sb(rhs.sb)
5407  {
5408  rhs.is = nullptr;
5409  rhs.sb = nullptr;
5410  }
5411 
5412  // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
5413  // ensure that std::char_traits<char>::eof() and the character 0xFF do not
5414  // end up as the same value, eg. 0xFFFFFFFF.
5415  std::char_traits<char>::int_type get_character()
5416  {
5417  auto res = sb->sbumpc();
5418  // set eof manually, as we don't use the istream interface.
5419  if (JSON_HEDLEY_UNLIKELY(res == std::char_traits<char>::eof()))
5420  {
5421  is->clear(is->rdstate() | std::ios::eofbit);
5422  }
5423  return res;
5424  }
5425 
5426  private:
5428  std::istream* is = nullptr;
5429  std::streambuf* sb = nullptr;
5430 };
5431 #endif // JSON_NO_IO
5432 
5433 // General-purpose iterator-based adapter. It might not be as fast as
5434 // theoretically possible for some containers, but it is extremely versatile.
5435 template<typename IteratorType>
5437 {
5438  public:
5439  using char_type = typename std::iterator_traits<IteratorType>::value_type;
5440 
5441  iterator_input_adapter(IteratorType first, IteratorType last)
5442  : current(std::move(first)), end(std::move(last))
5443  {}
5444 
5445  typename std::char_traits<char_type>::int_type get_character()
5446  {
5447  if (JSON_HEDLEY_LIKELY(current != end))
5448  {
5449  auto result = std::char_traits<char_type>::to_int_type(*current);
5450  std::advance(current, 1);
5451  return result;
5452  }
5453 
5454  return std::char_traits<char_type>::eof();
5455  }
5456 
5457  private:
5458  IteratorType current;
5459  IteratorType end;
5460 
5461  template<typename BaseInputAdapter, size_t T>
5463 
5464  bool empty() const
5465  {
5466  return current == end;
5467  }
5468 };
5469 
5470 
5471 template<typename BaseInputAdapter, size_t T>
5473 
5474 template<typename BaseInputAdapter>
5475 struct wide_string_input_helper<BaseInputAdapter, 4>
5476 {
5477  // UTF-32
5478  static void fill_buffer(BaseInputAdapter& input,
5479  std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5480  size_t& utf8_bytes_index,
5481  size_t& utf8_bytes_filled)
5482  {
5483  utf8_bytes_index = 0;
5484 
5485  if (JSON_HEDLEY_UNLIKELY(input.empty()))
5486  {
5487  utf8_bytes[0] = std::char_traits<char>::eof();
5488  utf8_bytes_filled = 1;
5489  }
5490  else
5491  {
5492  // get the current character
5493  const auto wc = input.get_character();
5494 
5495  // UTF-32 to UTF-8 encoding
5496  if (wc < 0x80)
5497  {
5498  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5499  utf8_bytes_filled = 1;
5500  }
5501  else if (wc <= 0x7FF)
5502  {
5503  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5504  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5505  utf8_bytes_filled = 2;
5506  }
5507  else if (wc <= 0xFFFF)
5508  {
5509  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5510  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5511  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5512  utf8_bytes_filled = 3;
5513  }
5514  else if (wc <= 0x10FFFF)
5515  {
5516  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5517  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5518  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5519  utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5520  utf8_bytes_filled = 4;
5521  }
5522  else
5523  {
5524  // unknown character
5525  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5526  utf8_bytes_filled = 1;
5527  }
5528  }
5529  }
5530 };
5531 
5532 template<typename BaseInputAdapter>
5533 struct wide_string_input_helper<BaseInputAdapter, 2>
5534 {
5535  // UTF-16
5536  static void fill_buffer(BaseInputAdapter& input,
5537  std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5538  size_t& utf8_bytes_index,
5539  size_t& utf8_bytes_filled)
5540  {
5541  utf8_bytes_index = 0;
5542 
5543  if (JSON_HEDLEY_UNLIKELY(input.empty()))
5544  {
5545  utf8_bytes[0] = std::char_traits<char>::eof();
5546  utf8_bytes_filled = 1;
5547  }
5548  else
5549  {
5550  // get the current character
5551  const auto wc = input.get_character();
5552 
5553  // UTF-16 to UTF-8 encoding
5554  if (wc < 0x80)
5555  {
5556  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5557  utf8_bytes_filled = 1;
5558  }
5559  else if (wc <= 0x7FF)
5560  {
5561  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u)));
5562  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5563  utf8_bytes_filled = 2;
5564  }
5565  else if (0xD800 > wc || wc >= 0xE000)
5566  {
5567  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u)));
5568  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5569  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5570  utf8_bytes_filled = 3;
5571  }
5572  else
5573  {
5574  if (JSON_HEDLEY_UNLIKELY(!input.empty()))
5575  {
5576  const auto wc2 = static_cast<unsigned int>(input.get_character());
5577  const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5578  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
5579  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
5580  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
5581  utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
5582  utf8_bytes_filled = 4;
5583  }
5584  else
5585  {
5586  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5587  utf8_bytes_filled = 1;
5588  }
5589  }
5590  }
5591  }
5592 };
5593 
5594 // Wraps another input apdater to convert wide character types into individual bytes.
5595 template<typename BaseInputAdapter, typename WideCharType>
5597 {
5598  public:
5599  using char_type = char;
5600 
5601  wide_string_input_adapter(BaseInputAdapter base)
5602  : base_adapter(base) {}
5603 
5604  typename std::char_traits<char>::int_type get_character() noexcept
5605  {
5606  // check if buffer needs to be filled
5608  {
5609  fill_buffer<sizeof(WideCharType)>();
5610 
5613  }
5614 
5615  // use buffer
5618  return utf8_bytes[utf8_bytes_index++];
5619  }
5620 
5621  private:
5622  BaseInputAdapter base_adapter;
5623 
5624  template<size_t T>
5626  {
5628  }
5629 
5631  std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5632 
5634  std::size_t utf8_bytes_index = 0;
5636  std::size_t utf8_bytes_filled = 0;
5637 };
5638 
5639 
5640 template<typename IteratorType, typename Enable = void>
5642 {
5643  using iterator_type = IteratorType;
5644  using char_type = typename std::iterator_traits<iterator_type>::value_type;
5646 
5647  static adapter_type create(IteratorType first, IteratorType last)
5648  {
5649  return adapter_type(std::move(first), std::move(last));
5650  }
5651 };
5652 
5653 template<typename T>
5655 {
5656  using value_type = typename std::iterator_traits<T>::value_type;
5657  enum
5658  {
5659  value = sizeof(value_type) > 1
5660  };
5661 };
5662 
5663 template<typename IteratorType>
5665 {
5666  using iterator_type = IteratorType;
5667  using char_type = typename std::iterator_traits<iterator_type>::value_type;
5670 
5671  static adapter_type create(IteratorType first, IteratorType last)
5672  {
5673  return adapter_type(base_adapter_type(std::move(first), std::move(last)));
5674  }
5675 };
5676 
5677 // General purpose iterator-based input
5678 template<typename IteratorType>
5679 typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
5680 {
5681  using factory_type = iterator_input_adapter_factory<IteratorType>;
5682  return factory_type::create(first, last);
5683 }
5684 
5685 // Convenience shorthand from container to iterator
5686 // Enables ADL on begin(container) and end(container)
5687 // Encloses the using declarations in namespace for not to leak them to outside scope
5688 
5689 namespace container_input_adapter_factory_impl
5690 {
5691 
5692 using std::begin;
5693 using std::end;
5694 
5695 template<typename ContainerType, typename Enable = void>
5697 
5698 template<typename ContainerType>
5699 struct container_input_adapter_factory< ContainerType,
5700  void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5701  {
5702  using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
5703 
5704  static adapter_type create(const ContainerType& container)
5705 {
5706  return input_adapter(begin(container), end(container));
5707 }
5708  };
5709 
5710 } // namespace container_input_adapter_factory_impl
5711 
5712 template<typename ContainerType>
5714 {
5716 }
5717 
5718 #ifndef JSON_NO_IO
5719 // Special cases with fast paths
5721 {
5722  return file_input_adapter(file);
5723 }
5724 
5725 inline input_stream_adapter input_adapter(std::istream& stream)
5726 {
5727  return input_stream_adapter(stream);
5728 }
5729 
5730 inline input_stream_adapter input_adapter(std::istream&& stream)
5731 {
5732  return input_stream_adapter(stream);
5733 }
5734 #endif // JSON_NO_IO
5735 
5736 using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
5737 
5738 // Null-delimited strings, and the like.
5739 template < typename CharT,
5740  typename std::enable_if <
5744  sizeof(typename std::remove_pointer<CharT>::type) == 1,
5745  int >::type = 0 >
5747 {
5748  auto length = std::strlen(reinterpret_cast<const char*>(b));
5749  const auto* ptr = reinterpret_cast<const char*>(b);
5750  return input_adapter(ptr, ptr + length);
5751 }
5752 
5753 template<typename T, std::size_t N>
5754 auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
5755 {
5756  return input_adapter(array, array + N);
5757 }
5758 
5759 // This class only handles inputs of input_buffer_adapter type.
5760 // It's required so that expressions like {ptr, len} can be implicitely casted
5761 // to the correct adapter.
5763 {
5764  public:
5765  template < typename CharT,
5766  typename std::enable_if <
5769  sizeof(typename std::remove_pointer<CharT>::type) == 1,
5770  int >::type = 0 >
5771  span_input_adapter(CharT b, std::size_t l)
5772  : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
5773 
5774  template<class IteratorType,
5775  typename std::enable_if<
5776  std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
5777  int>::type = 0>
5778  span_input_adapter(IteratorType first, IteratorType last)
5779  : ia(input_adapter(first, last)) {}
5780 
5782  {
5783  return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg)
5784  }
5785 
5786  private:
5788 };
5789 } // namespace detail
5790 } // namespace nlohmann
5791 
5792 // #include <nlohmann/detail/input/json_sax.hpp>
5793 
5794 
5795 #include <cstddef>
5796 #include <string> // string
5797 #include <utility> // move
5798 #include <vector> // vector
5799 
5800 // #include <nlohmann/detail/exceptions.hpp>
5801 
5802 // #include <nlohmann/detail/macro_scope.hpp>
5803 
5804 
5805 namespace nlohmann
5806 {
5807 
5816 template<typename BasicJsonType>
5817 struct json_sax
5818 {
5819  using number_integer_t = typename BasicJsonType::number_integer_t;
5820  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5821  using number_float_t = typename BasicJsonType::number_float_t;
5822  using string_t = typename BasicJsonType::string_t;
5823  using binary_t = typename BasicJsonType::binary_t;
5824 
5829  virtual bool null() = 0;
5830 
5836  virtual bool boolean(bool val) = 0;
5837 
5843  virtual bool number_integer(number_integer_t val) = 0;
5844 
5850  virtual bool number_unsigned(number_unsigned_t val) = 0;
5851 
5858  virtual bool number_float(number_float_t val, const string_t& s) = 0;
5859 
5866  virtual bool string(string_t& val) = 0;
5867 
5874  virtual bool binary(binary_t& val) = 0;
5875 
5882  virtual bool start_object(std::size_t elements) = 0;
5883 
5890  virtual bool key(string_t& val) = 0;
5891 
5896  virtual bool end_object() = 0;
5897 
5904  virtual bool start_array(std::size_t elements) = 0;
5905 
5910  virtual bool end_array() = 0;
5911 
5919  virtual bool parse_error(std::size_t position,
5920  const std::string& last_token,
5921  const detail::exception& ex) = 0;
5922 
5923  json_sax() = default;
5924  json_sax(const json_sax&) = default;
5925  json_sax(json_sax&&) noexcept = default;
5926  json_sax& operator=(const json_sax&) = default;
5927  json_sax& operator=(json_sax&&) noexcept = default;
5928  virtual ~json_sax() = default;
5929 };
5930 
5931 
5932 namespace detail
5933 {
5947 template<typename BasicJsonType>
5949 {
5950  public:
5951  using number_integer_t = typename BasicJsonType::number_integer_t;
5952  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5953  using number_float_t = typename BasicJsonType::number_float_t;
5954  using string_t = typename BasicJsonType::string_t;
5955  using binary_t = typename BasicJsonType::binary_t;
5956 
5962  explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
5963  : root(r), allow_exceptions(allow_exceptions_)
5964  {}
5965 
5966  // make class move-only
5967  json_sax_dom_parser(const json_sax_dom_parser&) = delete;
5968  json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
5970  json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
5971  ~json_sax_dom_parser() = default;
5972 
5973  bool null()
5974  {
5975  handle_value(nullptr);
5976  return true;
5977  }
5978 
5979  bool boolean(bool val)
5980  {
5981  handle_value(val);
5982  return true;
5983  }
5984 
5986  {
5987  handle_value(val);
5988  return true;
5989  }
5990 
5992  {
5993  handle_value(val);
5994  return true;
5995  }
5996 
5997  bool number_float(number_float_t val, const string_t& /*unused*/)
5998  {
5999  handle_value(val);
6000  return true;
6001  }
6002 
6003  bool string(string_t& val)
6004  {
6005  handle_value(val);
6006  return true;
6007  }
6008 
6009  bool binary(binary_t& val)
6010  {
6011  handle_value(std::move(val));
6012  return true;
6013  }
6014 
6015  bool start_object(std::size_t len)
6016  {
6017  ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6018 
6019  if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6020  {
6021  JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
6022  }
6023 
6024  return true;
6025  }
6026 
6027  bool key(string_t& val)
6028  {
6029  // add null at given key and store the reference for later
6030  object_element = &(ref_stack.back()->m_value.object->operator[](val));
6031  return true;
6032  }
6033 
6034  bool end_object()
6035  {
6036  ref_stack.back()->set_parents();
6037  ref_stack.pop_back();
6038  return true;
6039  }
6040 
6041  bool start_array(std::size_t len)
6042  {
6043  ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6044 
6045  if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6046  {
6047  JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
6048  }
6049 
6050  return true;
6051  }
6052 
6053  bool end_array()
6054  {
6055  ref_stack.back()->set_parents();
6056  ref_stack.pop_back();
6057  return true;
6058  }
6059 
6060  template<class Exception>
6061  bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
6062  const Exception& ex)
6063  {
6064  errored = true;
6065  static_cast<void>(ex);
6066  if (allow_exceptions)
6067  {
6068  JSON_THROW(ex);
6069  }
6070  return false;
6071  }
6072 
6073  constexpr bool is_errored() const
6074  {
6075  return errored;
6076  }
6077 
6078  private:
6085  template<typename Value>
6087  BasicJsonType* handle_value(Value&& v)
6088  {
6089  if (ref_stack.empty())
6090  {
6091  root = BasicJsonType(std::forward<Value>(v));
6092  return &root;
6093  }
6094 
6095  JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6096 
6097  if (ref_stack.back()->is_array())
6098  {
6099  ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6100  return &(ref_stack.back()->m_value.array->back());
6101  }
6102 
6103  JSON_ASSERT(ref_stack.back()->is_object());
6104  JSON_ASSERT(object_element);
6105  *object_element = BasicJsonType(std::forward<Value>(v));
6106  return object_element;
6107  }
6108 
6110  BasicJsonType& root;
6112  std::vector<BasicJsonType*> ref_stack {};
6114  BasicJsonType* object_element = nullptr;
6116  bool errored = false;
6118  const bool allow_exceptions = true;
6119 };
6120 
6121 template<typename BasicJsonType>
6123 {
6124  public:
6125  using number_integer_t = typename BasicJsonType::number_integer_t;
6126  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6127  using number_float_t = typename BasicJsonType::number_float_t;
6128  using string_t = typename BasicJsonType::string_t;
6129  using binary_t = typename BasicJsonType::binary_t;
6132 
6134  const parser_callback_t cb,
6135  const bool allow_exceptions_ = true)
6136  : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6137  {
6138  keep_stack.push_back(true);
6139  }
6140 
6141  // make class move-only
6143  json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6145  json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6146  ~json_sax_dom_callback_parser() = default;
6147 
6148  bool null()
6149  {
6150  handle_value(nullptr);
6151  return true;
6152  }
6153 
6154  bool boolean(bool val)
6155  {
6156  handle_value(val);
6157  return true;
6158  }
6159 
6161  {
6162  handle_value(val);
6163  return true;
6164  }
6165 
6167  {
6168  handle_value(val);
6169  return true;
6170  }
6171 
6172  bool number_float(number_float_t val, const string_t& /*unused*/)
6173  {
6174  handle_value(val);
6175  return true;
6176  }
6177 
6178  bool string(string_t& val)
6179  {
6180  handle_value(val);
6181  return true;
6182  }
6183 
6184  bool binary(binary_t& val)
6185  {
6186  handle_value(std::move(val));
6187  return true;
6188  }
6189 
6190  bool start_object(std::size_t len)
6191  {
6192  // check callback for object start
6193  const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
6194  keep_stack.push_back(keep);
6195 
6196  auto val = handle_value(BasicJsonType::value_t::object, true);
6197  ref_stack.push_back(val.second);
6198 
6199  // check object limit
6200  if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6201  {
6202  JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
6203  }
6204 
6205  return true;
6206  }
6207 
6208  bool key(string_t& val)
6209  {
6210  BasicJsonType k = BasicJsonType(val);
6211 
6212  // check callback for key
6213  const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6214  key_keep_stack.push_back(keep);
6215 
6216  // add discarded value at given key and store the reference for later
6217  if (keep && ref_stack.back())
6218  {
6219  object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
6220  }
6221 
6222  return true;
6223  }
6224 
6225  bool end_object()
6226  {
6227  if (ref_stack.back())
6228  {
6229  if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6230  {
6231  // discard object
6232  *ref_stack.back() = discarded;
6233  }
6234  else
6235  {
6236  ref_stack.back()->set_parents();
6237  }
6238  }
6239 
6240  JSON_ASSERT(!ref_stack.empty());
6241  JSON_ASSERT(!keep_stack.empty());
6242  ref_stack.pop_back();
6243  keep_stack.pop_back();
6244 
6245  if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6246  {
6247  // remove discarded value
6248  for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6249  {
6250  if (it->is_discarded())
6251  {
6252  ref_stack.back()->erase(it);
6253  break;
6254  }
6255  }
6256  }
6257 
6258  return true;
6259  }
6260 
6261  bool start_array(std::size_t len)
6262  {
6263  const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
6264  keep_stack.push_back(keep);
6265 
6266  auto val = handle_value(BasicJsonType::value_t::array, true);
6267  ref_stack.push_back(val.second);
6268 
6269  // check array limit
6270  if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6271  {
6272  JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
6273  }
6274 
6275  return true;
6276  }
6277 
6278  bool end_array()
6279  {
6280  bool keep = true;
6281 
6282  if (ref_stack.back())
6283  {
6284  keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6285  if (keep)
6286  {
6287  ref_stack.back()->set_parents();
6288  }
6289  else
6290  {
6291  // discard array
6292  *ref_stack.back() = discarded;
6293  }
6294  }
6295 
6296  JSON_ASSERT(!ref_stack.empty());
6297  JSON_ASSERT(!keep_stack.empty());
6298  ref_stack.pop_back();
6299  keep_stack.pop_back();
6300 
6301  // remove discarded value
6302  if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6303  {
6304  ref_stack.back()->m_value.array->pop_back();
6305  }
6306 
6307  return true;
6308  }
6309 
6310  template<class Exception>
6311  bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
6312  const Exception& ex)
6313  {
6314  errored = true;
6315  static_cast<void>(ex);
6316  if (allow_exceptions)
6317  {
6318  JSON_THROW(ex);
6319  }
6320  return false;
6321  }
6322 
6323  constexpr bool is_errored() const
6324  {
6325  return errored;
6326  }
6327 
6328  private:
6344  template<typename Value>
6345  std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
6346  {
6347  JSON_ASSERT(!keep_stack.empty());
6348 
6349  // do not handle this value if we know it would be added to a discarded
6350  // container
6351  if (!keep_stack.back())
6352  {
6353  return {false, nullptr};
6354  }
6355 
6356  // create value
6357  auto value = BasicJsonType(std::forward<Value>(v));
6358 
6359  // check callback
6360  const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
6361 
6362  // do not handle this value if we just learnt it shall be discarded
6363  if (!keep)
6364  {
6365  return {false, nullptr};
6366  }
6367 
6368  if (ref_stack.empty())
6369  {
6370  root = std::move(value);
6371  return {true, &root};
6372  }
6373 
6374  // skip this value if we already decided to skip the parent
6375  // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
6376  if (!ref_stack.back())
6377  {
6378  return {false, nullptr};
6379  }
6380 
6381  // we now only expect arrays and objects
6382  JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6383 
6384  // array
6385  if (ref_stack.back()->is_array())
6386  {
6387  ref_stack.back()->m_value.array->emplace_back(std::move(value));
6388  return {true, &(ref_stack.back()->m_value.array->back())};
6389  }
6390 
6391  // object
6392  JSON_ASSERT(ref_stack.back()->is_object());
6393  // check if we should store an element for the current key
6394  JSON_ASSERT(!key_keep_stack.empty());
6395  const bool store_element = key_keep_stack.back();
6396  key_keep_stack.pop_back();
6397 
6398  if (!store_element)
6399  {
6400  return {false, nullptr};
6401  }
6402 
6403  JSON_ASSERT(object_element);
6404  *object_element = std::move(value);
6405  return {true, object_element};
6406  }
6407 
6409  BasicJsonType& root;
6411  std::vector<BasicJsonType*> ref_stack {};
6413  std::vector<bool> keep_stack {};
6415  std::vector<bool> key_keep_stack {};
6417  BasicJsonType* object_element = nullptr;
6419  bool errored = false;
6421  const parser_callback_t callback = nullptr;
6423  const bool allow_exceptions = true;
6425  BasicJsonType discarded = BasicJsonType::value_t::discarded;
6426 };
6427 
6428 template<typename BasicJsonType>
6430 {
6431  public:
6432  using number_integer_t = typename BasicJsonType::number_integer_t;
6433  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6434  using number_float_t = typename BasicJsonType::number_float_t;
6435  using string_t = typename BasicJsonType::string_t;
6436  using binary_t = typename BasicJsonType::binary_t;
6437 
6438  bool null()
6439  {
6440  return true;
6441  }
6442 
6443  bool boolean(bool /*unused*/)
6444  {
6445  return true;
6446  }
6447 
6449  {
6450  return true;
6451  }
6452 
6454  {
6455  return true;
6456  }
6457 
6458  bool number_float(number_float_t /*unused*/, const string_t& /*unused*/)
6459  {
6460  return true;
6461  }
6462 
6463  bool string(string_t& /*unused*/)
6464  {
6465  return true;
6466  }
6467 
6468  bool binary(binary_t& /*unused*/)
6469  {
6470  return true;
6471  }
6472 
6473  bool start_object(std::size_t /*unused*/ = std::size_t(-1))
6474  {
6475  return true;
6476  }
6477 
6478  bool key(string_t& /*unused*/)
6479  {
6480  return true;
6481  }
6482 
6483  bool end_object()
6484  {
6485  return true;
6486  }
6487 
6488  bool start_array(std::size_t /*unused*/ = std::size_t(-1))
6489  {
6490  return true;
6491  }
6492 
6493  bool end_array()
6494  {
6495  return true;
6496  }
6497 
6498  bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/)
6499  {
6500  return false;
6501  }
6502 };
6503 } // namespace detail
6504 
6505 } // namespace nlohmann
6506 
6507 // #include <nlohmann/detail/input/lexer.hpp>
6508 
6509 
6510 #include <array> // array
6511 #include <clocale> // localeconv
6512 #include <cstddef> // size_t
6513 #include <cstdio> // snprintf
6514 #include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
6515 #include <initializer_list> // initializer_list
6516 #include <string> // char_traits, string
6517 #include <utility> // move
6518 #include <vector> // vector
6519 
6520 // #include <nlohmann/detail/input/input_adapters.hpp>
6521 
6522 // #include <nlohmann/detail/input/position_t.hpp>
6523 
6524 // #include <nlohmann/detail/macro_scope.hpp>
6525 
6526 
6527 namespace nlohmann
6528 {
6529 namespace detail
6530 {
6532 // lexer //
6534 
6535 template<typename BasicJsonType>
6537 {
6538  public:
6540  enum class token_type
6541  {
6542  uninitialized,
6543  literal_true,
6544  literal_false,
6545  literal_null,
6546  value_string,
6547  value_unsigned,
6548  value_integer,
6549  value_float,
6550  begin_array,
6551  begin_object,
6552  end_array,
6553  end_object,
6554  name_separator,
6555  value_separator,
6556  parse_error,
6557  end_of_input,
6559  };
6560 
6564  static const char* token_type_name(const token_type t) noexcept
6565  {
6566  switch (t)
6567  {
6569  return "<uninitialized>";
6571  return "true literal";
6573  return "false literal";
6575  return "null literal";
6577  return "string literal";
6581  return "number literal";
6583  return "'['";
6585  return "'{'";
6586  case token_type::end_array:
6587  return "']'";
6589  return "'}'";
6591  return "':'";
6593  return "','";
6595  return "<parse error>";
6597  return "end of input";
6599  return "'[', '{', or a literal";
6600  // LCOV_EXCL_START
6601  default: // catch non-enum values
6602  return "unknown token";
6603  // LCOV_EXCL_STOP
6604  }
6605  }
6606 };
6612 template<typename BasicJsonType, typename InputAdapterType>
6613 class lexer : public lexer_base<BasicJsonType>
6614 {
6615  using number_integer_t = typename BasicJsonType::number_integer_t;
6616  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6617  using number_float_t = typename BasicJsonType::number_float_t;
6618  using string_t = typename BasicJsonType::string_t;
6619  using char_type = typename InputAdapterType::char_type;
6620  using char_int_type = typename std::char_traits<char_type>::int_type;
6621 
6622  public:
6624 
6625  explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept
6626  : ia(std::move(adapter))
6627  , ignore_comments(ignore_comments_)
6629  {}
6630 
6631  // delete because of pointer members
6632  lexer(const lexer&) = delete;
6633  lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6634  lexer& operator=(lexer&) = delete;
6635  lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6636  ~lexer() = default;
6637 
6638  private:
6640  // locales
6642 
6645  static char get_decimal_point() noexcept
6646  {
6647  const auto* loc = localeconv();
6648  JSON_ASSERT(loc != nullptr);
6649  return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
6650  }
6651 
6653  // scan functions
6655 
6672  {
6673  // this function only makes sense after reading `\u`
6674  JSON_ASSERT(current == 'u');
6675  int codepoint = 0;
6676 
6677  const auto factors = { 12u, 8u, 4u, 0u };
6678  for (const auto factor : factors)
6679  {
6680  get();
6681 
6682  if (current >= '0' && current <= '9')
6683  {
6684  codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
6685  }
6686  else if (current >= 'A' && current <= 'F')
6687  {
6688  codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
6689  }
6690  else if (current >= 'a' && current <= 'f')
6691  {
6692  codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
6693  }
6694  else
6695  {
6696  return -1;
6697  }
6698  }
6699 
6700  JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6701  return codepoint;
6702  }
6703 
6719  bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6720  {
6721  JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6722  add(current);
6723 
6724  for (auto range = ranges.begin(); range != ranges.end(); ++range)
6725  {
6726  get();
6727  if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
6728  {
6729  add(current);
6730  }
6731  else
6732  {
6733  error_message = "invalid string: ill-formed UTF-8 byte";
6734  return false;
6735  }
6736  }
6737 
6738  return true;
6739  }
6740 
6757  {
6758  // reset token_buffer (ignore opening quote)
6759  reset();
6760 
6761  // we entered the function by reading an open quote
6762  JSON_ASSERT(current == '\"');
6763 
6764  while (true)
6765  {
6766  // get next character
6767  switch (get())
6768  {
6769  // end of file while parsing string
6770  case std::char_traits<char_type>::eof():
6771  {
6772  error_message = "invalid string: missing closing quote";
6773  return token_type::parse_error;
6774  }
6775 
6776  // closing quote
6777  case '\"':
6778  {
6779  return token_type::value_string;
6780  }
6781 
6782  // escapes
6783  case '\\':
6784  {
6785  switch (get())
6786  {
6787  // quotation mark
6788  case '\"':
6789  add('\"');
6790  break;
6791  // reverse solidus
6792  case '\\':
6793  add('\\');
6794  break;
6795  // solidus
6796  case '/':
6797  add('/');
6798  break;
6799  // backspace
6800  case 'b':
6801  add('\b');
6802  break;
6803  // form feed
6804  case 'f':
6805  add('\f');
6806  break;
6807  // line feed
6808  case 'n':
6809  add('\n');
6810  break;
6811  // carriage return
6812  case 'r':
6813  add('\r');
6814  break;
6815  // tab
6816  case 't':
6817  add('\t');
6818  break;
6819 
6820  // unicode escapes
6821  case 'u':
6822  {
6823  const int codepoint1 = get_codepoint();
6824  int codepoint = codepoint1; // start with codepoint1
6825 
6826  if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1))
6827  {
6828  error_message = "invalid string: '\\u' must be followed by 4 hex digits";
6829  return token_type::parse_error;
6830  }
6831 
6832  // check if code point is a high surrogate
6833  if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6834  {
6835  // expect next \uxxxx entry
6836  if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u'))
6837  {
6838  const int codepoint2 = get_codepoint();
6839 
6840  if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1))
6841  {
6842  error_message = "invalid string: '\\u' must be followed by 4 hex digits";
6843  return token_type::parse_error;
6844  }
6845 
6846  // check if codepoint2 is a low surrogate
6847  if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF))
6848  {
6849  // overwrite codepoint
6850  codepoint = static_cast<int>(
6851  // high surrogate occupies the most significant 22 bits
6852  (static_cast<unsigned int>(codepoint1) << 10u)
6853  // low surrogate occupies the least significant 15 bits
6854  + static_cast<unsigned int>(codepoint2)
6855  // there is still the 0xD800, 0xDC00 and 0x10000 noise
6856  // in the result so we have to subtract with:
6857  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
6858  - 0x35FDC00u);
6859  }
6860  else
6861  {
6862  error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6863  return token_type::parse_error;
6864  }
6865  }
6866  else
6867  {
6868  error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6869  return token_type::parse_error;
6870  }
6871  }
6872  else
6873  {
6874  if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF))
6875  {
6876  error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6877  return token_type::parse_error;
6878  }
6879  }
6880 
6881  // result of the above calculation yields a proper codepoint
6882  JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6883 
6884  // translate codepoint into bytes
6885  if (codepoint < 0x80)
6886  {
6887  // 1-byte characters: 0xxxxxxx (ASCII)
6888  add(static_cast<char_int_type>(codepoint));
6889  }
6890  else if (codepoint <= 0x7FF)
6891  {
6892  // 2-byte characters: 110xxxxx 10xxxxxx
6893  add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
6894  add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6895  }
6896  else if (codepoint <= 0xFFFF)
6897  {
6898  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
6899  add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
6900  add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6901  add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6902  }
6903  else
6904  {
6905  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
6906  add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
6907  add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6908  add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6909  add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6910  }
6911 
6912  break;
6913  }
6914 
6915  // other characters after escape
6916  default:
6917  error_message = "invalid string: forbidden character after backslash";
6918  return token_type::parse_error;
6919  }
6920 
6921  break;
6922  }
6923 
6924  // invalid control characters
6925  case 0x00:
6926  {
6927  error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6928  return token_type::parse_error;
6929  }
6930 
6931  case 0x01:
6932  {
6933  error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6934  return token_type::parse_error;
6935  }
6936 
6937  case 0x02:
6938  {
6939  error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6940  return token_type::parse_error;
6941  }
6942 
6943  case 0x03:
6944  {
6945  error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6946  return token_type::parse_error;
6947  }
6948 
6949  case 0x04:
6950  {
6951  error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6952  return token_type::parse_error;
6953  }
6954 
6955  case 0x05:
6956  {
6957  error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6958  return token_type::parse_error;
6959  }
6960 
6961  case 0x06:
6962  {
6963  error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6964  return token_type::parse_error;
6965  }
6966 
6967  case 0x07:
6968  {
6969  error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6970  return token_type::parse_error;
6971  }
6972 
6973  case 0x08:
6974  {
6975  error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6976  return token_type::parse_error;
6977  }
6978 
6979  case 0x09:
6980  {
6981  error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6982  return token_type::parse_error;
6983  }
6984 
6985  case 0x0A:
6986  {
6987  error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6988  return token_type::parse_error;
6989  }
6990 
6991  case 0x0B:
6992  {
6993  error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B";
6994  return token_type::parse_error;
6995  }
6996 
6997  case 0x0C:
6998  {
6999  error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7000  return token_type::parse_error;
7001  }
7002 
7003  case 0x0D:
7004  {
7005  error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7006  return token_type::parse_error;
7007  }
7008 
7009  case 0x0E:
7010  {
7011  error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E";
7012  return token_type::parse_error;
7013  }
7014 
7015  case 0x0F:
7016  {
7017  error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F";
7018  return token_type::parse_error;
7019  }
7020 
7021  case 0x10:
7022  {
7023  error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7024  return token_type::parse_error;
7025  }
7026 
7027  case 0x11:
7028  {
7029  error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7030  return token_type::parse_error;
7031  }
7032 
7033  case 0x12:
7034  {
7035  error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7036  return token_type::parse_error;
7037  }
7038 
7039  case 0x13:
7040  {
7041  error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7042  return token_type::parse_error;
7043  }
7044 
7045  case 0x14:
7046  {
7047  error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7048  return token_type::parse_error;
7049  }
7050 
7051  case 0x15:
7052  {
7053  error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7054  return token_type::parse_error;
7055  }
7056 
7057  case 0x16:
7058  {
7059  error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7060  return token_type::parse_error;
7061  }
7062 
7063  case 0x17:
7064  {
7065  error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7066  return token_type::parse_error;
7067  }
7068 
7069  case 0x18:
7070  {
7071  error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7072  return token_type::parse_error;
7073  }
7074 
7075  case 0x19:
7076  {
7077  error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7078  return token_type::parse_error;
7079  }
7080 
7081  case 0x1A:
7082  {
7083  error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7084  return token_type::parse_error;
7085  }
7086 
7087  case 0x1B:
7088  {
7089  error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7090  return token_type::parse_error;
7091  }
7092 
7093  case 0x1C:
7094  {
7095  error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C";
7096  return token_type::parse_error;
7097  }
7098 
7099  case 0x1D:
7100  {
7101  error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D";
7102  return token_type::parse_error;
7103  }
7104 
7105  case 0x1E:
7106  {
7107  error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E";
7108  return token_type::parse_error;
7109  }
7110 
7111  case 0x1F:
7112  {
7113  error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F";
7114  return token_type::parse_error;
7115  }
7116 
7117  // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace))
7118  case 0x20:
7119  case 0x21:
7120  case 0x23:
7121  case 0x24:
7122  case 0x25:
7123  case 0x26:
7124  case 0x27:
7125  case 0x28:
7126  case 0x29:
7127  case 0x2A:
7128  case 0x2B:
7129  case 0x2C:
7130  case 0x2D:
7131  case 0x2E:
7132  case 0x2F:
7133  case 0x30:
7134  case 0x31:
7135  case 0x32:
7136  case 0x33:
7137  case 0x34:
7138  case 0x35:
7139  case 0x36:
7140  case 0x37:
7141  case 0x38:
7142  case 0x39:
7143  case 0x3A:
7144  case 0x3B:
7145  case 0x3C:
7146  case 0x3D:
7147  case 0x3E:
7148  case 0x3F:
7149  case 0x40:
7150  case 0x41:
7151  case 0x42:
7152  case 0x43:
7153  case 0x44:
7154  case 0x45:
7155  case 0x46:
7156  case 0x47:
7157  case 0x48:
7158  case 0x49:
7159  case 0x4A:
7160  case 0x4B:
7161  case 0x4C:
7162  case 0x4D:
7163  case 0x4E:
7164  case 0x4F:
7165  case 0x50:
7166  case 0x51:
7167  case 0x52:
7168  case 0x53:
7169  case 0x54:
7170  case 0x55:
7171  case 0x56:
7172  case 0x57:
7173  case 0x58:
7174  case 0x59:
7175  case 0x5A:
7176  case 0x5B:
7177  case 0x5D:
7178  case 0x5E:
7179  case 0x5F:
7180  case 0x60:
7181  case 0x61:
7182  case 0x62:
7183  case 0x63:
7184  case 0x64:
7185  case 0x65:
7186  case 0x66:
7187  case 0x67:
7188  case 0x68:
7189  case 0x69:
7190  case 0x6A:
7191  case 0x6B:
7192  case 0x6C:
7193  case 0x6D:
7194  case 0x6E:
7195  case 0x6F:
7196  case 0x70:
7197  case 0x71:
7198  case 0x72:
7199  case 0x73:
7200  case 0x74:
7201  case 0x75:
7202  case 0x76:
7203  case 0x77:
7204  case 0x78:
7205  case 0x79:
7206  case 0x7A:
7207  case 0x7B:
7208  case 0x7C:
7209  case 0x7D:
7210  case 0x7E:
7211  case 0x7F:
7212  {
7213  add(current);
7214  break;
7215  }
7216 
7217  // U+0080..U+07FF: bytes C2..DF 80..BF
7218  case 0xC2:
7219  case 0xC3:
7220  case 0xC4:
7221  case 0xC5:
7222  case 0xC6:
7223  case 0xC7:
7224  case 0xC8:
7225  case 0xC9:
7226  case 0xCA:
7227  case 0xCB:
7228  case 0xCC:
7229  case 0xCD:
7230  case 0xCE:
7231  case 0xCF:
7232  case 0xD0:
7233  case 0xD1:
7234  case 0xD2:
7235  case 0xD3:
7236  case 0xD4:
7237  case 0xD5:
7238  case 0xD6:
7239  case 0xD7:
7240  case 0xD8:
7241  case 0xD9:
7242  case 0xDA:
7243  case 0xDB:
7244  case 0xDC:
7245  case 0xDD:
7246  case 0xDE:
7247  case 0xDF:
7248  {
7249  if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
7250  {
7251  return token_type::parse_error;
7252  }
7253  break;
7254  }
7255 
7256  // U+0800..U+0FFF: bytes E0 A0..BF 80..BF
7257  case 0xE0:
7258  {
7259  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
7260  {
7261  return token_type::parse_error;
7262  }
7263  break;
7264  }
7265 
7266  // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF
7267  // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF
7268  case 0xE1:
7269  case 0xE2:
7270  case 0xE3:
7271  case 0xE4:
7272  case 0xE5:
7273  case 0xE6:
7274  case 0xE7:
7275  case 0xE8:
7276  case 0xE9:
7277  case 0xEA:
7278  case 0xEB:
7279  case 0xEC:
7280  case 0xEE:
7281  case 0xEF:
7282  {
7283  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
7284  {
7285  return token_type::parse_error;
7286  }
7287  break;
7288  }
7289 
7290  // U+D000..U+D7FF: bytes ED 80..9F 80..BF
7291  case 0xED:
7292  {
7293  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
7294  {
7295  return token_type::parse_error;
7296  }
7297  break;
7298  }
7299 
7300  // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
7301  case 0xF0:
7302  {
7303  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
7304  {
7305  return token_type::parse_error;
7306  }
7307  break;
7308  }
7309 
7310  // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
7311  case 0xF1:
7312  case 0xF2:
7313  case 0xF3:
7314  {
7315  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
7316  {
7317  return token_type::parse_error;
7318  }
7319  break;
7320  }
7321 
7322  // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
7323  case 0xF4:
7324  {
7325  if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
7326  {
7327  return token_type::parse_error;
7328  }
7329  break;
7330  }
7331 
7332  // remaining bytes (80..C1 and F5..FF) are ill-formed
7333  default:
7334  {
7335  error_message = "invalid string: ill-formed UTF-8 byte";
7336  return token_type::parse_error;
7337  }
7338  }
7339  }
7340  }
7341 
7347  {
7348  switch (get())
7349  {
7350  // single-line comments skip input until a newline or EOF is read
7351  case '/':
7352  {
7353  while (true)
7354  {
7355  switch (get())
7356  {
7357  case '\n':
7358  case '\r':
7359  case std::char_traits<char_type>::eof():
7360  case '\0':
7361  return true;
7362 
7363  default:
7364  break;
7365  }
7366  }
7367  }
7368 
7369  // multi-line comments skip input until */ is read
7370  case '*':
7371  {
7372  while (true)
7373  {
7374  switch (get())
7375  {
7376  case std::char_traits<char_type>::eof():
7377  case '\0':
7378  {
7379  error_message = "invalid comment; missing closing '*/'";
7380  return false;
7381  }
7382 
7383  case '*':
7384  {
7385  switch (get())
7386  {
7387  case '/':
7388  return true;
7389 
7390  default:
7391  {
7392  unget();
7393  continue;
7394  }
7395  }
7396  }
7397 
7398  default:
7399  continue;
7400  }
7401  }
7402  }
7403 
7404  // unexpected character after reading '/'
7405  default:
7406  {
7407  error_message = "invalid comment; expecting '/' or '*' after '/'";
7408  return false;
7409  }
7410  }
7411  }
7412 
7414  static void strtof(float& f, const char* str, char** endptr) noexcept
7415  {
7416  f = std::strtof(str, endptr);
7417  }
7418 
7420  static void strtof(double& f, const char* str, char** endptr) noexcept
7421  {
7422  f = std::strtod(str, endptr);
7423  }
7424 
7426  static void strtof(long double& f, const char* str, char** endptr) noexcept
7427  {
7428  f = std::strtold(str, endptr);
7429  }
7430 
7471  token_type scan_number() // lgtm [cpp/use-of-goto]
7472  {
7473  // reset token_buffer to store the number's bytes
7474  reset();
7475 
7476  // the type of the parsed number; initially set to unsigned; will be
7477  // changed if minus sign, decimal point or exponent is read
7478  token_type number_type = token_type::value_unsigned;
7479 
7480  // state (init): we just found out we need to scan a number
7481  switch (current)
7482  {
7483  case '-':
7484  {
7485  add(current);
7486  goto scan_number_minus;
7487  }
7488 
7489  case '0':
7490  {
7491  add(current);
7492  goto scan_number_zero;
7493  }
7494 
7495  case '1':
7496  case '2':
7497  case '3':
7498  case '4':
7499  case '5':
7500  case '6':
7501  case '7':
7502  case '8':
7503  case '9':
7504  {
7505  add(current);
7506  goto scan_number_any1;
7507  }
7508 
7509  // all other characters are rejected outside scan_number()
7510  default: // LCOV_EXCL_LINE
7511  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
7512  }
7513 
7514 scan_number_minus:
7515  // state: we just parsed a leading minus sign
7516  number_type = token_type::value_integer;
7517  switch (get())
7518  {
7519  case '0':
7520  {
7521  add(current);
7522  goto scan_number_zero;
7523  }
7524 
7525  case '1':
7526  case '2':
7527  case '3':
7528  case '4':
7529  case '5':
7530  case '6':
7531  case '7':
7532  case '8':
7533  case '9':
7534  {
7535  add(current);
7536  goto scan_number_any1;
7537  }
7538 
7539  default:
7540  {
7541  error_message = "invalid number; expected digit after '-'";
7542  return token_type::parse_error;
7543  }
7544  }
7545 
7546 scan_number_zero:
7547  // state: we just parse a zero (maybe with a leading minus sign)
7548  switch (get())
7549  {
7550  case '.':
7551  {
7553  goto scan_number_decimal1;
7554  }
7555 
7556  case 'e':
7557  case 'E':
7558  {
7559  add(current);
7560  goto scan_number_exponent;
7561  }
7562 
7563  default:
7564  goto scan_number_done;
7565  }
7566 
7567 scan_number_any1:
7568  // state: we just parsed a number 0-9 (maybe with a leading minus sign)
7569  switch (get())
7570  {
7571  case '0':
7572  case '1':
7573  case '2':
7574  case '3':
7575  case '4':
7576  case '5':
7577  case '6':
7578  case '7':
7579  case '8':
7580  case '9':
7581  {
7582  add(current);
7583  goto scan_number_any1;
7584  }
7585 
7586  case '.':
7587  {
7589  goto scan_number_decimal1;
7590  }
7591 
7592  case 'e':
7593  case 'E':
7594  {
7595  add(current);
7596  goto scan_number_exponent;
7597  }
7598 
7599  default:
7600  goto scan_number_done;
7601  }
7602 
7603 scan_number_decimal1:
7604  // state: we just parsed a decimal point
7605  number_type = token_type::value_float;
7606  switch (get())
7607  {
7608  case '0':
7609  case '1':
7610  case '2':
7611  case '3':
7612  case '4':
7613  case '5':
7614  case '6':
7615  case '7':
7616  case '8':
7617  case '9':
7618  {
7619  add(current);
7620  goto scan_number_decimal2;
7621  }
7622 
7623  default:
7624  {
7625  error_message = "invalid number; expected digit after '.'";
7626  return token_type::parse_error;
7627  }
7628  }
7629 
7630 scan_number_decimal2:
7631  // we just parsed at least one number after a decimal point
7632  switch (get())
7633  {
7634  case '0':
7635  case '1':
7636  case '2':
7637  case '3':
7638  case '4':
7639  case '5':
7640  case '6':
7641  case '7':
7642  case '8':
7643  case '9':
7644  {
7645  add(current);
7646  goto scan_number_decimal2;
7647  }
7648 
7649  case 'e':
7650  case 'E':
7651  {
7652  add(current);
7653  goto scan_number_exponent;
7654  }
7655 
7656  default:
7657  goto scan_number_done;
7658  }
7659 
7660 scan_number_exponent:
7661  // we just parsed an exponent
7662  number_type = token_type::value_float;
7663  switch (get())
7664  {
7665  case '+':
7666  case '-':
7667  {
7668  add(current);
7669  goto scan_number_sign;
7670  }
7671 
7672  case '0':
7673  case '1':
7674  case '2':
7675  case '3':
7676  case '4':
7677  case '5':
7678  case '6':
7679  case '7':
7680  case '8':
7681  case '9':
7682  {
7683  add(current);
7684  goto scan_number_any2;
7685  }
7686 
7687  default:
7688  {
7689  error_message =
7690  "invalid number; expected '+', '-', or digit after exponent";
7691  return token_type::parse_error;
7692  }
7693  }
7694 
7695 scan_number_sign:
7696  // we just parsed an exponent sign
7697  switch (get())
7698  {
7699  case '0':
7700  case '1':
7701  case '2':
7702  case '3':
7703  case '4':
7704  case '5':
7705  case '6':
7706  case '7':
7707  case '8':
7708  case '9':
7709  {
7710  add(current);
7711  goto scan_number_any2;
7712  }
7713 
7714  default:
7715  {
7716  error_message = "invalid number; expected digit after exponent sign";
7717  return token_type::parse_error;
7718  }
7719  }
7720 
7721 scan_number_any2:
7722  // we just parsed a number after the exponent or exponent sign
7723  switch (get())
7724  {
7725  case '0':
7726  case '1':
7727  case '2':
7728  case '3':
7729  case '4':
7730  case '5':
7731  case '6':
7732  case '7':
7733  case '8':
7734  case '9':
7735  {
7736  add(current);
7737  goto scan_number_any2;
7738  }
7739 
7740  default:
7741  goto scan_number_done;
7742  }
7743 
7744 scan_number_done:
7745  // unget the character after the number (we only read it to know that
7746  // we are done scanning a number)
7747  unget();
7748 
7749  char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
7750  errno = 0;
7751 
7752  // try to parse integers first and fall back to floats
7753  if (number_type == token_type::value_unsigned)
7754  {
7755  const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7756 
7757  // we checked the number format before
7758  JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7759 
7760  if (errno == 0)
7761  {
7762  value_unsigned = static_cast<number_unsigned_t>(x);
7763  if (value_unsigned == x)
7764  {
7765  return token_type::value_unsigned;
7766  }
7767  }
7768  }
7769  else if (number_type == token_type::value_integer)
7770  {
7771  const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7772 
7773  // we checked the number format before
7774  JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7775 
7776  if (errno == 0)
7777  {
7778  value_integer = static_cast<number_integer_t>(x);
7779  if (value_integer == x)
7780  {
7781  return token_type::value_integer;
7782  }
7783  }
7784  }
7785 
7786  // this code is reached if we parse a floating-point number or if an
7787  // integer conversion above failed
7788  strtof(value_float, token_buffer.data(), &endptr);
7789 
7790  // we checked the number format before
7791  JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7792 
7793  return token_type::value_float;
7794  }
7795 
7802  token_type scan_literal(const char_type* literal_text, const std::size_t length,
7803  token_type return_type)
7804  {
7805  JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
7806  for (std::size_t i = 1; i < length; ++i)
7807  {
7808  if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
7809  {
7810  error_message = "invalid literal";
7811  return token_type::parse_error;
7812  }
7813  }
7814  return return_type;
7815  }
7816 
7818  // input management
7820 
7822  void reset() noexcept
7823  {
7824  token_buffer.clear();
7825  token_string.clear();
7826  token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7827  }
7828 
7829  /*
7830  @brief get next character from the input
7831 
7832  This function provides the interface to the used input adapter. It does
7833  not throw in case the input reached EOF, but returns a
7834  `std::char_traits<char>::eof()` in that case. Stores the scanned characters
7835  for use in error messages.
7836 
7837  @return character read from the input
7838  */
7840  {
7843 
7844  if (next_unget)
7845  {
7846  // just reset the next_unget variable and work with current
7847  next_unget = false;
7848  }
7849  else
7850  {
7851  current = ia.get_character();
7852  }
7853 
7854  if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
7855  {
7856  token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7857  }
7858 
7859  if (current == '\n')
7860  {
7861  ++position.lines_read;
7863  }
7864 
7865  return current;
7866  }
7867 
7876  void unget()
7877  {
7878  next_unget = true;
7879 
7881 
7882  // in case we "unget" a newline, we have to also decrement the lines_read
7884  {
7885  if (position.lines_read > 0)
7886  {
7887  --position.lines_read;
7888  }
7889  }
7890  else
7891  {
7893  }
7894 
7895  if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
7896  {
7897  JSON_ASSERT(!token_string.empty());
7898  token_string.pop_back();
7899  }
7900  }
7901 
7904  {
7905  token_buffer.push_back(static_cast<typename string_t::value_type>(c));
7906  }
7907 
7908  public:
7910  // value getters
7912 
7914  constexpr number_integer_t get_number_integer() const noexcept
7915  {
7916  return value_integer;
7917  }
7918 
7920  constexpr number_unsigned_t get_number_unsigned() const noexcept
7921  {
7922  return value_unsigned;
7923  }
7924 
7926  constexpr number_float_t get_number_float() const noexcept
7927  {
7928  return value_float;
7929  }
7930 
7933  {
7934  return token_buffer;
7935  }
7936 
7938  // diagnostics
7940 
7942  constexpr position_t get_position() const noexcept
7943  {
7944  return position;
7945  }
7946 
7950  std::string get_token_string() const
7951  {
7952  // escape control characters
7953  std::string result;
7954  for (const auto c : token_string)
7955  {
7956  if (static_cast<unsigned char>(c) <= '\x1F')
7957  {
7958  // escape control characters
7959  std::array<char, 9> cs{{}};
7960  (std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
7961  result += cs.data();
7962  }
7963  else
7964  {
7965  // add character as is
7966  result.push_back(static_cast<std::string::value_type>(c));
7967  }
7968  }
7969 
7970  return result;
7971  }
7972 
7975  constexpr const char* get_error_message() const noexcept
7976  {
7977  return error_message;
7978  }
7979 
7981  // actual scanner
7983 
7988  bool skip_bom()
7989  {
7990  if (get() == 0xEF)
7991  {
7992  // check if we completely parse the BOM
7993  return get() == 0xBB && get() == 0xBF;
7994  }
7995 
7996  // the first character is not the beginning of the BOM; unget it to
7997  // process is later
7998  unget();
7999  return true;
8000  }
8001 
8003  {
8004  do
8005  {
8006  get();
8007  }
8008  while (current == ' ' || current == '\t' || current == '\n' || current == '\r');
8009  }
8010 
8012  {
8013  // initially, skip the BOM
8014  if (position.chars_read_total == 0 && !skip_bom())
8015  {
8016  error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given";
8017  return token_type::parse_error;
8018  }
8019 
8020  // read next character and ignore whitespace
8021  skip_whitespace();
8022 
8023  // ignore comments
8024  while (ignore_comments && current == '/')
8025  {
8026  if (!scan_comment())
8027  {
8028  return token_type::parse_error;
8029  }
8030 
8031  // skip following whitespace
8032  skip_whitespace();
8033  }
8034 
8035  switch (current)
8036  {
8037  // structural characters
8038  case '[':
8039  return token_type::begin_array;
8040  case ']':
8041  return token_type::end_array;
8042  case '{':
8043  return token_type::begin_object;
8044  case '}':
8045  return token_type::end_object;
8046  case ':':
8047  return token_type::name_separator;
8048  case ',':
8049  return token_type::value_separator;
8050 
8051  // literals
8052  case 't':
8053  {
8054  std::array<char_type, 4> true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}};
8055  return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8056  }
8057  case 'f':
8058  {
8059  std::array<char_type, 5> false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}};
8060  return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8061  }
8062  case 'n':
8063  {
8064  std::array<char_type, 4> null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}};
8065  return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8066  }
8067 
8068  // string
8069  case '\"':
8070  return scan_string();
8071 
8072  // number
8073  case '-':
8074  case '0':
8075  case '1':
8076  case '2':
8077  case '3':
8078  case '4':
8079  case '5':
8080  case '6':
8081  case '7':
8082  case '8':
8083  case '9':
8084  return scan_number();
8085 
8086  // end of input (the null byte is needed when parsing from
8087  // string literals)
8088  case '\0':
8089  case std::char_traits<char_type>::eof():
8090  return token_type::end_of_input;
8091 
8092  // error
8093  default:
8094  error_message = "invalid literal";
8095  return token_type::parse_error;
8096  }
8097  }
8098 
8099  private:
8101  InputAdapterType ia;
8102 
8104  const bool ignore_comments = false;
8105 
8107  char_int_type current = std::char_traits<char_type>::eof();
8108 
8110  bool next_unget = false;
8111 
8114 
8116  std::vector<char_type> token_string {};
8117 
8120 
8122  const char* error_message = "";
8123 
8124  // number values
8128 
8131 };
8132 } // namespace detail
8133 } // namespace nlohmann
8134 
8135 // #include <nlohmann/detail/macro_scope.hpp>
8136 
8137 // #include <nlohmann/detail/meta/is_sax.hpp>
8138 
8139 
8140 #include <cstdint> // size_t
8141 #include <utility> // declval
8142 #include <string> // string
8143 
8144 // #include <nlohmann/detail/meta/detected.hpp>
8145 
8146 // #include <nlohmann/detail/meta/type_traits.hpp>
8147 
8148 
8149 namespace nlohmann
8150 {
8151 namespace detail
8152 {
8153 template<typename T>
8154 using null_function_t = decltype(std::declval<T&>().null());
8155 
8156 template<typename T>
8157 using boolean_function_t =
8158  decltype(std::declval<T&>().boolean(std::declval<bool>()));
8159 
8160 template<typename T, typename Integer>
8162  decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8163 
8164 template<typename T, typename Unsigned>
8166  decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8167 
8168 template<typename T, typename Float, typename String>
8169 using number_float_function_t = decltype(std::declval<T&>().number_float(
8170  std::declval<Float>(), std::declval<const String&>()));
8171 
8172 template<typename T, typename String>
8173 using string_function_t =
8174  decltype(std::declval<T&>().string(std::declval<String&>()));
8175 
8176 template<typename T, typename Binary>
8177 using binary_function_t =
8178  decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8179 
8180 template<typename T>
8182  decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8183 
8184 template<typename T, typename String>
8185 using key_function_t =
8186  decltype(std::declval<T&>().key(std::declval<String&>()));
8187 
8188 template<typename T>
8189 using end_object_function_t = decltype(std::declval<T&>().end_object());
8190 
8191 template<typename T>
8192 using start_array_function_t =
8193  decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8194 
8195 template<typename T>
8196 using end_array_function_t = decltype(std::declval<T&>().end_array());
8197 
8198 template<typename T, typename Exception>
8199 using parse_error_function_t = decltype(std::declval<T&>().parse_error(
8200  std::declval<std::size_t>(), std::declval<const std::string&>(),
8201  std::declval<const Exception&>()));
8202 
8203 template<typename SAX, typename BasicJsonType>
8204 struct is_sax
8205 {
8206  private:
8208  "BasicJsonType must be of type basic_json<...>");
8209 
8210  using number_integer_t = typename BasicJsonType::number_integer_t;
8211  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
8212  using number_float_t = typename BasicJsonType::number_float_t;
8213  using string_t = typename BasicJsonType::string_t;
8214  using binary_t = typename BasicJsonType::binary_t;
8215  using exception_t = typename BasicJsonType::exception;
8216 
8217  public:
8218  static constexpr bool value =
8232 };
8233 
8234 template<typename SAX, typename BasicJsonType>
8236 {
8237  private:
8239  "BasicJsonType must be of type basic_json<...>");
8240 
8241  using number_integer_t = typename BasicJsonType::number_integer_t;
8242  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
8243  using number_float_t = typename BasicJsonType::number_float_t;
8244  using string_t = typename BasicJsonType::string_t;
8245  using binary_t = typename BasicJsonType::binary_t;
8246  using exception_t = typename BasicJsonType::exception;
8247 
8248  public:
8250  "Missing/invalid function: bool null()");
8252  "Missing/invalid function: bool boolean(bool)");
8254  "Missing/invalid function: bool boolean(bool)");
8255  static_assert(
8257  number_integer_t>::value,
8258  "Missing/invalid function: bool number_integer(number_integer_t)");
8259  static_assert(
8261  number_unsigned_t>::value,
8262  "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8263  static_assert(is_detected_exact<bool, number_float_function_t, SAX,
8264  number_float_t, string_t>::value,
8265  "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8266  static_assert(
8268  "Missing/invalid function: bool string(string_t&)");
8269  static_assert(
8271  "Missing/invalid function: bool binary(binary_t&)");
8273  "Missing/invalid function: bool start_object(std::size_t)");
8275  "Missing/invalid function: bool key(string_t&)");
8277  "Missing/invalid function: bool end_object()");
8279  "Missing/invalid function: bool start_array(std::size_t)");
8281  "Missing/invalid function: bool end_array()");
8282  static_assert(
8284  "Missing/invalid function: bool parse_error(std::size_t, const "
8285  "std::string&, const exception&)");
8286 };
8287 } // namespace detail
8288 } // namespace nlohmann
8289 
8290 // #include <nlohmann/detail/meta/type_traits.hpp>
8291 
8292 // #include <nlohmann/detail/value_t.hpp>
8293 
8294 
8295 namespace nlohmann
8296 {
8297 namespace detail
8298 {
8299 
8302 {
8303  error,
8304  ignore,
8305  store
8306 };
8307 
8315 static inline bool little_endianess(int num = 1) noexcept
8316 {
8317  return *reinterpret_cast<char*>(&num) == 1;
8318 }
8319 
8320 
8322 // binary reader //
8324 
8328 template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
8330 {
8331  using number_integer_t = typename BasicJsonType::number_integer_t;
8332  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
8333  using number_float_t = typename BasicJsonType::number_float_t;
8334  using string_t = typename BasicJsonType::string_t;
8335  using binary_t = typename BasicJsonType::binary_t;
8336  using json_sax_t = SAX;
8337  using char_type = typename InputAdapterType::char_type;
8338  using char_int_type = typename std::char_traits<char_type>::int_type;
8339 
8340  public:
8346  explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter))
8347  {
8349  }
8350 
8351  // make class move-only
8352  binary_reader(const binary_reader&) = delete;
8353  binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
8354  binary_reader& operator=(const binary_reader&) = delete;
8355  binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
8356  ~binary_reader() = default;
8357 
8367  bool sax_parse(const input_format_t format,
8368  json_sax_t* sax_,
8369  const bool strict = true,
8370  const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
8371  {
8372  sax = sax_;
8373  bool result = false;
8374 
8375  switch (format)
8376  {
8377  case input_format_t::bson:
8379  break;
8380 
8381  case input_format_t::cbor:
8382  result = parse_cbor_internal(true, tag_handler);
8383  break;
8384 
8387  break;
8388 
8391  break;
8392 
8393  case input_format_t::json: // LCOV_EXCL_LINE
8394  default: // LCOV_EXCL_LINE
8395  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
8396  }
8397 
8398  // strict mode: next byte must be EOF
8399  if (result && strict)
8400  {
8401  if (format == input_format_t::ubjson)
8402  {
8403  get_ignore_noop();
8404  }
8405  else
8406  {
8407  get();
8408  }
8409 
8410  if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
8411  {
8412  return sax->parse_error(chars_read, get_token_string(),
8413  parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType()));
8414  }
8415  }
8416 
8417  return result;
8418  }
8419 
8420  private:
8422  // BSON //
8424 
8430  {
8431  std::int32_t document_size{};
8432  get_number<std::int32_t, true>(input_format_t::bson, document_size);
8433 
8434  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
8435  {
8436  return false;
8437  }
8438 
8439  if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false)))
8440  {
8441  return false;
8442  }
8443 
8444  return sax->end_object();
8445  }
8446 
8455  {
8456  auto out = std::back_inserter(result);
8457  while (true)
8458  {
8459  get();
8461  {
8462  return false;
8463  }
8464  if (current == 0x00)
8465  {
8466  return true;
8467  }
8468  *out++ = static_cast<typename string_t::value_type>(current);
8469  }
8470  }
8471 
8483  template<typename NumberType>
8484  bool get_bson_string(const NumberType len, string_t& result)
8485  {
8486  if (JSON_HEDLEY_UNLIKELY(len < 1))
8487  {
8488  auto last_token = get_token_string();
8489  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType()));
8490  }
8491 
8492  return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != std::char_traits<char_type>::eof();
8493  }
8494 
8504  template<typename NumberType>
8505  bool get_bson_binary(const NumberType len, binary_t& result)
8506  {
8507  if (JSON_HEDLEY_UNLIKELY(len < 0))
8508  {
8509  auto last_token = get_token_string();
8510  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType()));
8511  }
8512 
8513  // All BSON binary values have a subtype
8514  std::uint8_t subtype{};
8515  get_number<std::uint8_t>(input_format_t::bson, subtype);
8516  result.set_subtype(subtype);
8517 
8518  return get_binary(input_format_t::bson, len, result);
8519  }
8520 
8532  const std::size_t element_type_parse_position)
8533  {
8534  switch (element_type)
8535  {
8536  case 0x01: // double
8537  {
8538  double number{};
8539  return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), "");
8540  }
8541 
8542  case 0x02: // string
8543  {
8544  std::int32_t len{};
8545  string_t value;
8546  return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8547  }
8548 
8549  case 0x03: // object
8550  {
8551  return parse_bson_internal();
8552  }
8553 
8554  case 0x04: // array
8555  {
8556  return parse_bson_array();
8557  }
8558 
8559  case 0x05: // binary
8560  {
8561  std::int32_t len{};
8562  binary_t value;
8563  return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8564  }
8565 
8566  case 0x08: // boolean
8567  {
8568  return sax->boolean(get() != 0);
8569  }
8570 
8571  case 0x0A: // null
8572  {
8573  return sax->null();
8574  }
8575 
8576  case 0x10: // int32
8577  {
8578  std::int32_t value{};
8579  return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
8580  }
8581 
8582  case 0x12: // int64
8583  {
8584  std::int64_t value{};
8585  return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
8586  }
8587 
8588  default: // anything else not supported (yet)
8589  {
8590  std::array<char, 3> cr{{}};
8591  (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
8592  return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
8593  }
8594  }
8595  }
8596 
8609  bool parse_bson_element_list(const bool is_array)
8610  {
8611  string_t key;
8612 
8613  while (auto element_type = get())
8614  {
8616  {
8617  return false;
8618  }
8619 
8620  const std::size_t element_type_parse_position = chars_read;
8622  {
8623  return false;
8624  }
8625 
8626  if (!is_array && !sax->key(key))
8627  {
8628  return false;
8629  }
8630 
8631  if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8632  {
8633  return false;
8634  }
8635 
8636  // get_bson_cstr only appends
8637  key.clear();
8638  }
8639 
8640  return true;
8641  }
8642 
8648  {
8649  std::int32_t document_size{};
8650  get_number<std::int32_t, true>(input_format_t::bson, document_size);
8651 
8652  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
8653  {
8654  return false;
8655  }
8656 
8657  if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true)))
8658  {
8659  return false;
8660  }
8661 
8662  return sax->end_array();
8663  }
8664 
8666  // CBOR //
8668 
8677  bool parse_cbor_internal(const bool get_char,
8678  const cbor_tag_handler_t tag_handler)
8679  {
8680  switch (get_char ? get() : current)
8681  {
8682  // EOF
8683  case std::char_traits<char_type>::eof():
8684  return unexpect_eof(input_format_t::cbor, "value");
8685 
8686  // Integer 0x00..0x17 (0..23)
8687  case 0x00:
8688  case 0x01:
8689  case 0x02:
8690  case 0x03:
8691  case 0x04:
8692  case 0x05:
8693  case 0x06:
8694  case 0x07:
8695  case 0x08:
8696  case 0x09:
8697  case 0x0A:
8698  case 0x0B:
8699  case 0x0C:
8700  case 0x0D:
8701  case 0x0E:
8702  case 0x0F:
8703  case 0x10:
8704  case 0x11:
8705  case 0x12:
8706  case 0x13:
8707  case 0x14:
8708  case 0x15:
8709  case 0x16:
8710  case 0x17:
8711  return sax->number_unsigned(static_cast<number_unsigned_t>(current));
8712 
8713  case 0x18: // Unsigned integer (one-byte uint8_t follows)
8714  {
8715  std::uint8_t number{};
8716  return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8717  }
8718 
8719  case 0x19: // Unsigned integer (two-byte uint16_t follows)
8720  {
8721  std::uint16_t number{};
8722  return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8723  }
8724 
8725  case 0x1A: // Unsigned integer (four-byte uint32_t follows)
8726  {
8727  std::uint32_t number{};
8728  return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8729  }
8730 
8731  case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
8732  {
8733  std::uint64_t number{};
8734  return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8735  }
8736 
8737  // Negative integer -1-0x00..-1-0x17 (-1..-24)
8738  case 0x20:
8739  case 0x21:
8740  case 0x22:
8741  case 0x23:
8742  case 0x24:
8743  case 0x25:
8744  case 0x26:
8745  case 0x27:
8746  case 0x28:
8747  case 0x29:
8748  case 0x2A:
8749  case 0x2B:
8750  case 0x2C:
8751  case 0x2D:
8752  case 0x2E:
8753  case 0x2F:
8754  case 0x30:
8755  case 0x31:
8756  case 0x32:
8757  case 0x33:
8758  case 0x34:
8759  case 0x35:
8760  case 0x36:
8761  case 0x37:
8762  return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
8763 
8764  case 0x38: // Negative integer (one-byte uint8_t follows)
8765  {
8766  std::uint8_t number{};
8767  return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8768  }
8769 
8770  case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
8771  {
8772  std::uint16_t number{};
8773  return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8774  }
8775 
8776  case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
8777  {
8778  std::uint32_t number{};
8779  return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8780  }
8781 
8782  case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
8783  {
8784  std::uint64_t number{};
8785  return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1)
8786  - static_cast<number_integer_t>(number));
8787  }
8788 
8789  // Binary data (0x00..0x17 bytes follow)
8790  case 0x40:
8791  case 0x41:
8792  case 0x42:
8793  case 0x43:
8794  case 0x44:
8795  case 0x45:
8796  case 0x46:
8797  case 0x47:
8798  case 0x48:
8799  case 0x49:
8800  case 0x4A:
8801  case 0x4B:
8802  case 0x4C:
8803  case 0x4D:
8804  case 0x4E:
8805  case 0x4F:
8806  case 0x50:
8807  case 0x51:
8808  case 0x52:
8809  case 0x53:
8810  case 0x54:
8811  case 0x55:
8812  case 0x56:
8813  case 0x57:
8814  case 0x58: // Binary data (one-byte uint8_t for n follows)
8815  case 0x59: // Binary data (two-byte uint16_t for n follow)
8816  case 0x5A: // Binary data (four-byte uint32_t for n follow)
8817  case 0x5B: // Binary data (eight-byte uint64_t for n follow)
8818  case 0x5F: // Binary data (indefinite length)
8819  {
8820  binary_t b;
8821  return get_cbor_binary(b) && sax->binary(b);
8822  }
8823 
8824  // UTF-8 string (0x00..0x17 bytes follow)
8825  case 0x60:
8826  case 0x61:
8827  case 0x62:
8828  case 0x63:
8829  case 0x64:
8830  case 0x65:
8831  case 0x66:
8832  case 0x67:
8833  case 0x68:
8834  case 0x69:
8835  case 0x6A:
8836  case 0x6B:
8837  case 0x6C:
8838  case 0x6D:
8839  case 0x6E:
8840  case 0x6F:
8841  case 0x70:
8842  case 0x71:
8843  case 0x72:
8844  case 0x73:
8845  case 0x74:
8846  case 0x75:
8847  case 0x76:
8848  case 0x77:
8849  case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
8850  case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
8851  case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
8852  case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
8853  case 0x7F: // UTF-8 string (indefinite length)
8854  {
8855  string_t s;
8856  return get_cbor_string(s) && sax->string(s);
8857  }
8858 
8859  // array (0x00..0x17 data items follow)
8860  case 0x80:
8861  case 0x81:
8862  case 0x82:
8863  case 0x83:
8864  case 0x84:
8865  case 0x85:
8866  case 0x86:
8867  case 0x87:
8868  case 0x88:
8869  case 0x89:
8870  case 0x8A:
8871  case 0x8B:
8872  case 0x8C:
8873  case 0x8D:
8874  case 0x8E:
8875  case 0x8F:
8876  case 0x90:
8877  case 0x91:
8878  case 0x92:
8879  case 0x93:
8880  case 0x94:
8881  case 0x95:
8882  case 0x96:
8883  case 0x97:
8884  return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8885 
8886  case 0x98: // array (one-byte uint8_t for n follows)
8887  {
8888  std::uint8_t len{};
8889  return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8890  }
8891 
8892  case 0x99: // array (two-byte uint16_t for n follow)
8893  {
8894  std::uint16_t len{};
8895  return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8896  }
8897 
8898  case 0x9A: // array (four-byte uint32_t for n follow)
8899  {
8900  std::uint32_t len{};
8901  return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8902  }
8903 
8904  case 0x9B: // array (eight-byte uint64_t for n follow)
8905  {
8906  std::uint64_t len{};
8907  return get_number(input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(len), tag_handler);
8908  }
8909 
8910  case 0x9F: // array (indefinite length)
8911  return get_cbor_array(std::size_t(-1), tag_handler);
8912 
8913  // map (0x00..0x17 pairs of data items follow)
8914  case 0xA0:
8915  case 0xA1:
8916  case 0xA2:
8917  case 0xA3:
8918  case 0xA4:
8919  case 0xA5:
8920  case 0xA6:
8921  case 0xA7:
8922  case 0xA8:
8923  case 0xA9:
8924  case 0xAA:
8925  case 0xAB:
8926  case 0xAC:
8927  case 0xAD:
8928  case 0xAE:
8929  case 0xAF:
8930  case 0xB0:
8931  case 0xB1:
8932  case 0xB2:
8933  case 0xB3:
8934  case 0xB4:
8935  case 0xB5:
8936  case 0xB6:
8937  case 0xB7:
8938  return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8939 
8940  case 0xB8: // map (one-byte uint8_t for n follows)
8941  {
8942  std::uint8_t len{};
8943  return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8944  }
8945 
8946  case 0xB9: // map (two-byte uint16_t for n follow)
8947  {
8948  std::uint16_t len{};
8949  return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8950  }
8951 
8952  case 0xBA: // map (four-byte uint32_t for n follow)
8953  {
8954  std::uint32_t len{};
8955  return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8956  }
8957 
8958  case 0xBB: // map (eight-byte uint64_t for n follow)
8959  {
8960  std::uint64_t len{};
8961  return get_number(input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(len), tag_handler);
8962  }
8963 
8964  case 0xBF: // map (indefinite length)
8965  return get_cbor_object(std::size_t(-1), tag_handler);
8966 
8967  case 0xC6: // tagged item
8968  case 0xC7:
8969  case 0xC8:
8970  case 0xC9:
8971  case 0xCA:
8972  case 0xCB:
8973  case 0xCC:
8974  case 0xCD:
8975  case 0xCE:
8976  case 0xCF:
8977  case 0xD0:
8978  case 0xD1:
8979  case 0xD2:
8980  case 0xD3:
8981  case 0xD4:
8982  case 0xD8: // tagged item (1 bytes follow)
8983  case 0xD9: // tagged item (2 bytes follow)
8984  case 0xDA: // tagged item (4 bytes follow)
8985  case 0xDB: // tagged item (8 bytes follow)
8986  {
8987  switch (tag_handler)
8988  {
8990  {
8991  auto last_token = get_token_string();
8992  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
8993  }
8994 
8996  {
8997  // ignore binary subtype
8998  switch (current)
8999  {
9000  case 0xD8:
9001  {
9002  std::uint8_t subtype_to_ignore{};
9003  get_number(input_format_t::cbor, subtype_to_ignore);
9004  break;
9005  }
9006  case 0xD9:
9007  {
9008  std::uint16_t subtype_to_ignore{};
9009  get_number(input_format_t::cbor, subtype_to_ignore);
9010  break;
9011  }
9012  case 0xDA:
9013  {
9014  std::uint32_t subtype_to_ignore{};
9015  get_number(input_format_t::cbor, subtype_to_ignore);
9016  break;
9017  }
9018  case 0xDB:
9019  {
9020  std::uint64_t subtype_to_ignore{};
9021  get_number(input_format_t::cbor, subtype_to_ignore);
9022  break;
9023  }
9024  default:
9025  break;
9026  }
9027  return parse_cbor_internal(true, tag_handler);
9028  }
9029 
9031  {
9032  binary_t b;
9033  // use binary subtype and store in binary container
9034  switch (current)
9035  {
9036  case 0xD8:
9037  {
9038  std::uint8_t subtype{};
9039  get_number(input_format_t::cbor, subtype);
9040  b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9041  break;
9042  }
9043  case 0xD9:
9044  {
9045  std::uint16_t subtype{};
9046  get_number(input_format_t::cbor, subtype);
9047  b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9048  break;
9049  }
9050  case 0xDA:
9051  {
9052  std::uint32_t subtype{};
9053  get_number(input_format_t::cbor, subtype);
9054  b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9055  break;
9056  }
9057  case 0xDB:
9058  {
9059  std::uint64_t subtype{};
9060  get_number(input_format_t::cbor, subtype);
9061  b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9062  break;
9063  }
9064  default:
9065  return parse_cbor_internal(true, tag_handler);
9066  }
9067  get();
9068  return get_cbor_binary(b) && sax->binary(b);
9069  }
9070 
9071  default: // LCOV_EXCL_LINE
9072  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
9073  return false; // LCOV_EXCL_LINE
9074  }
9075  }
9076 
9077  case 0xF4: // false
9078  return sax->boolean(false);
9079 
9080  case 0xF5: // true
9081  return sax->boolean(true);
9082 
9083  case 0xF6: // null
9084  return sax->null();
9085 
9086  case 0xF9: // Half-Precision Float (two-byte IEEE 754)
9087  {
9088  const auto byte1_raw = get();
9090  {
9091  return false;
9092  }
9093  const auto byte2_raw = get();
9095  {
9096  return false;
9097  }
9098 
9099  const auto byte1 = static_cast<unsigned char>(byte1_raw);
9100  const auto byte2 = static_cast<unsigned char>(byte2_raw);
9101 
9102  // code from RFC 7049, Appendix D, Figure 3:
9103  // As half-precision floating-point numbers were only added
9104  // to IEEE 754 in 2008, today's programming platforms often
9105  // still only have limited support for them. It is very
9106  // easy to include at least decoding support for them even
9107  // without such support. An example of a small decoder for
9108  // half-precision floating-point numbers in the C language
9109  // is shown in Fig. 3.
9110  const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2);
9111  const double val = [&half]
9112  {
9113  const int exp = (half >> 10u) & 0x1Fu;
9114  const unsigned int mant = half & 0x3FFu;
9115  JSON_ASSERT(0 <= exp&& exp <= 32);
9116  JSON_ASSERT(mant <= 1024);
9117  switch (exp)
9118  {
9119  case 0:
9120  return std::ldexp(mant, -24);
9121  case 31:
9122  return (mant == 0)
9123  ? std::numeric_limits<double>::infinity()
9124  : std::numeric_limits<double>::quiet_NaN();
9125  default:
9126  return std::ldexp(mant + 1024, exp - 25);
9127  }
9128  }();
9129  return sax->number_float((half & 0x8000u) != 0
9130  ? static_cast<number_float_t>(-val)
9131  : static_cast<number_float_t>(val), "");
9132  }
9133 
9134  case 0xFA: // Single-Precision Float (four-byte IEEE 754)
9135  {
9136  float number{};
9137  return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), "");
9138  }
9139 
9140  case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
9141  {
9142  double number{};
9143  return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), "");
9144  }
9145 
9146  default: // anything else (0xFF is handled inside the other types)
9147  {
9148  auto last_token = get_token_string();
9149  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
9150  }
9151  }
9152  }
9153 
9166  {
9168  {
9169  return false;
9170  }
9171 
9172  switch (current)
9173  {
9174  // UTF-8 string (0x00..0x17 bytes follow)
9175  case 0x60:
9176  case 0x61:
9177  case 0x62:
9178  case 0x63:
9179  case 0x64:
9180  case 0x65:
9181  case 0x66:
9182  case 0x67:
9183  case 0x68:
9184  case 0x69:
9185  case 0x6A:
9186  case 0x6B:
9187  case 0x6C:
9188  case 0x6D:
9189  case 0x6E:
9190  case 0x6F:
9191  case 0x70:
9192  case 0x71:
9193  case 0x72:
9194  case 0x73:
9195  case 0x74:
9196  case 0x75:
9197  case 0x76:
9198  case 0x77:
9199  {
9200  return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
9201  }
9202 
9203  case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
9204  {
9205  std::uint8_t len{};
9207  }
9208 
9209  case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
9210  {
9211  std::uint16_t len{};
9213  }
9214 
9215  case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
9216  {
9217  std::uint32_t len{};
9219  }
9220 
9221  case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
9222  {
9223  std::uint64_t len{};
9225  }
9226 
9227  case 0x7F: // UTF-8 string (indefinite length)
9228  {
9229  while (get() != 0xFF)
9230  {
9231  string_t chunk;
9232  if (!get_cbor_string(chunk))
9233  {
9234  return false;
9235  }
9236  result.append(chunk);
9237  }
9238  return true;
9239  }
9240 
9241  default:
9242  {
9243  auto last_token = get_token_string();
9244  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType()));
9245  }
9246  }
9247  }
9248 
9261  {
9263  {
9264  return false;
9265  }
9266 
9267  switch (current)
9268  {
9269  // Binary data (0x00..0x17 bytes follow)
9270  case 0x40:
9271  case 0x41:
9272  case 0x42:
9273  case 0x43:
9274  case 0x44:
9275  case 0x45:
9276  case 0x46:
9277  case 0x47:
9278  case 0x48:
9279  case 0x49:
9280  case 0x4A:
9281  case 0x4B:
9282  case 0x4C:
9283  case 0x4D:
9284  case 0x4E:
9285  case 0x4F:
9286  case 0x50:
9287  case 0x51:
9288  case 0x52:
9289  case 0x53:
9290  case 0x54:
9291  case 0x55:
9292  case 0x56:
9293  case 0x57:
9294  {
9295  return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
9296  }
9297 
9298  case 0x58: // Binary data (one-byte uint8_t for n follows)
9299  {
9300  std::uint8_t len{};
9301  return get_number(input_format_t::cbor, len) &&
9303  }
9304 
9305  case 0x59: // Binary data (two-byte uint16_t for n follow)
9306  {
9307  std::uint16_t len{};
9308  return get_number(input_format_t::cbor, len) &&
9310  }
9311 
9312  case 0x5A: // Binary data (four-byte uint32_t for n follow)
9313  {
9314  std::uint32_t len{};
9315  return get_number(input_format_t::cbor, len) &&
9317  }
9318 
9319  case 0x5B: // Binary data (eight-byte uint64_t for n follow)
9320  {
9321  std::uint64_t len{};
9322  return get_number(input_format_t::cbor, len) &&
9324  }
9325 
9326  case 0x5F: // Binary data (indefinite length)
9327  {
9328  while (get() != 0xFF)
9329  {
9330  binary_t chunk;
9331  if (!get_cbor_binary(chunk))
9332  {
9333  return false;
9334  }
9335  result.insert(result.end(), chunk.begin(), chunk.end());
9336  }
9337  return true;
9338  }
9339 
9340  default:
9341  {
9342  auto last_token = get_token_string();
9343  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType()));
9344  }
9345  }
9346  }
9347 
9354  bool get_cbor_array(const std::size_t len,
9355  const cbor_tag_handler_t tag_handler)
9356  {
9357  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
9358  {
9359  return false;
9360  }
9361 
9362  if (len != std::size_t(-1))
9363  {
9364  for (std::size_t i = 0; i < len; ++i)
9365  {
9366  if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
9367  {
9368  return false;
9369  }
9370  }
9371  }
9372  else
9373  {
9374  while (get() != 0xFF)
9375  {
9376  if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler)))
9377  {
9378  return false;
9379  }
9380  }
9381  }
9382 
9383  return sax->end_array();
9384  }
9385 
9392  bool get_cbor_object(const std::size_t len,
9393  const cbor_tag_handler_t tag_handler)
9394  {
9395  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
9396  {
9397  return false;
9398  }
9399 
9400  if (len != 0)
9401  {
9402  string_t key;
9403  if (len != std::size_t(-1))
9404  {
9405  for (std::size_t i = 0; i < len; ++i)
9406  {
9407  get();
9408  if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
9409  {
9410  return false;
9411  }
9412 
9413  if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
9414  {
9415  return false;
9416  }
9417  key.clear();
9418  }
9419  }
9420  else
9421  {
9422  while (get() != 0xFF)
9423  {
9424  if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
9425  {
9426  return false;
9427  }
9428 
9429  if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
9430  {
9431  return false;
9432  }
9433  key.clear();
9434  }
9435  }
9436  }
9437 
9438  return sax->end_object();
9439  }
9440 
9442  // MsgPack //
9444 
9449  {
9450  switch (get())
9451  {
9452  // EOF
9453  case std::char_traits<char_type>::eof():
9454  return unexpect_eof(input_format_t::msgpack, "value");
9455 
9456  // positive fixint
9457  case 0x00:
9458  case 0x01:
9459  case 0x02:
9460  case 0x03:
9461  case 0x04:
9462  case 0x05:
9463  case 0x06:
9464  case 0x07:
9465  case 0x08:
9466  case 0x09:
9467  case 0x0A:
9468  case 0x0B:
9469  case 0x0C:
9470  case 0x0D:
9471  case 0x0E:
9472  case 0x0F:
9473  case 0x10:
9474  case 0x11:
9475  case 0x12:
9476  case 0x13:
9477  case 0x14:
9478  case 0x15:
9479  case 0x16:
9480  case 0x17:
9481  case 0x18:
9482  case 0x19:
9483  case 0x1A:
9484  case 0x1B:
9485  case 0x1C:
9486  case 0x1D:
9487  case 0x1E:
9488  case 0x1F:
9489  case 0x20:
9490  case 0x21:
9491  case 0x22:
9492  case 0x23:
9493  case 0x24:
9494  case 0x25:
9495  case 0x26:
9496  case 0x27:
9497  case 0x28:
9498  case 0x29:
9499  case 0x2A:
9500  case 0x2B:
9501  case 0x2C:
9502  case 0x2D:
9503  case 0x2E:
9504  case 0x2F:
9505  case 0x30:
9506  case 0x31:
9507  case 0x32:
9508  case 0x33:
9509  case 0x34:
9510  case 0x35:
9511  case 0x36:
9512  case 0x37:
9513  case 0x38:
9514  case 0x39:
9515  case 0x3A:
9516  case 0x3B:
9517  case 0x3C:
9518  case 0x3D:
9519  case 0x3E:
9520  case 0x3F:
9521  case 0x40:
9522  case 0x41:
9523  case 0x42:
9524  case 0x43:
9525  case 0x44:
9526  case 0x45:
9527  case 0x46:
9528  case 0x47:
9529  case 0x48:
9530  case 0x49:
9531  case 0x4A:
9532  case 0x4B:
9533  case 0x4C:
9534  case 0x4D:
9535  case 0x4E:
9536  case 0x4F:
9537  case 0x50:
9538  case 0x51:
9539  case 0x52:
9540  case 0x53:
9541  case 0x54:
9542  case 0x55:
9543  case 0x56:
9544  case 0x57:
9545  case 0x58:
9546  case 0x59:
9547  case 0x5A:
9548  case 0x5B:
9549  case 0x5C:
9550  case 0x5D:
9551  case 0x5E:
9552  case 0x5F:
9553  case 0x60:
9554  case 0x61:
9555  case 0x62:
9556  case 0x63:
9557  case 0x64:
9558  case 0x65:
9559  case 0x66:
9560  case 0x67:
9561  case 0x68:
9562  case 0x69:
9563  case 0x6A:
9564  case 0x6B:
9565  case 0x6C:
9566  case 0x6D:
9567  case 0x6E:
9568  case 0x6F:
9569  case 0x70:
9570  case 0x71:
9571  case 0x72:
9572  case 0x73:
9573  case 0x74:
9574  case 0x75:
9575  case 0x76:
9576  case 0x77:
9577  case 0x78:
9578  case 0x79:
9579  case 0x7A:
9580  case 0x7B:
9581  case 0x7C:
9582  case 0x7D:
9583  case 0x7E:
9584  case 0x7F:
9585  return sax->number_unsigned(static_cast<number_unsigned_t>(current));
9586 
9587  // fixmap
9588  case 0x80:
9589  case 0x81:
9590  case 0x82:
9591  case 0x83:
9592  case 0x84:
9593  case 0x85:
9594  case 0x86:
9595  case 0x87:
9596  case 0x88:
9597  case 0x89:
9598  case 0x8A:
9599  case 0x8B:
9600  case 0x8C:
9601  case 0x8D:
9602  case 0x8E:
9603  case 0x8F:
9604  return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9605 
9606  // fixarray
9607  case 0x90:
9608  case 0x91:
9609  case 0x92:
9610  case 0x93:
9611  case 0x94:
9612  case 0x95:
9613  case 0x96:
9614  case 0x97:
9615  case 0x98:
9616  case 0x99:
9617  case 0x9A:
9618  case 0x9B:
9619  case 0x9C:
9620  case 0x9D:
9621  case 0x9E:
9622  case 0x9F:
9623  return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9624 
9625  // fixstr
9626  case 0xA0:
9627  case 0xA1:
9628  case 0xA2:
9629  case 0xA3:
9630  case 0xA4:
9631  case 0xA5:
9632  case 0xA6:
9633  case 0xA7:
9634  case 0xA8:
9635  case 0xA9:
9636  case 0xAA:
9637  case 0xAB:
9638  case 0xAC:
9639  case 0xAD:
9640  case 0xAE:
9641  case 0xAF:
9642  case 0xB0:
9643  case 0xB1:
9644  case 0xB2:
9645  case 0xB3:
9646  case 0xB4:
9647  case 0xB5:
9648  case 0xB6:
9649  case 0xB7:
9650  case 0xB8:
9651  case 0xB9:
9652  case 0xBA:
9653  case 0xBB:
9654  case 0xBC:
9655  case 0xBD:
9656  case 0xBE:
9657  case 0xBF:
9658  case 0xD9: // str 8
9659  case 0xDA: // str 16
9660  case 0xDB: // str 32
9661  {
9662  string_t s;
9663  return get_msgpack_string(s) && sax->string(s);
9664  }
9665 
9666  case 0xC0: // nil
9667  return sax->null();
9668 
9669  case 0xC2: // false
9670  return sax->boolean(false);
9671 
9672  case 0xC3: // true
9673  return sax->boolean(true);
9674 
9675  case 0xC4: // bin 8
9676  case 0xC5: // bin 16
9677  case 0xC6: // bin 32
9678  case 0xC7: // ext 8
9679  case 0xC8: // ext 16
9680  case 0xC9: // ext 32
9681  case 0xD4: // fixext 1
9682  case 0xD5: // fixext 2
9683  case 0xD6: // fixext 4
9684  case 0xD7: // fixext 8
9685  case 0xD8: // fixext 16
9686  {
9687  binary_t b;
9688  return get_msgpack_binary(b) && sax->binary(b);
9689  }
9690 
9691  case 0xCA: // float 32
9692  {
9693  float number{};
9694  return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), "");
9695  }
9696 
9697  case 0xCB: // float 64
9698  {
9699  double number{};
9700  return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), "");
9701  }
9702 
9703  case 0xCC: // uint 8
9704  {
9705  std::uint8_t number{};
9706  return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9707  }
9708 
9709  case 0xCD: // uint 16
9710  {
9711  std::uint16_t number{};
9712  return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9713  }
9714 
9715  case 0xCE: // uint 32
9716  {
9717  std::uint32_t number{};
9718  return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9719  }
9720 
9721  case 0xCF: // uint 64
9722  {
9723  std::uint64_t number{};
9724  return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9725  }
9726 
9727  case 0xD0: // int 8
9728  {
9729  std::int8_t number{};
9730  return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9731  }
9732 
9733  case 0xD1: // int 16
9734  {
9735  std::int16_t number{};
9736  return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9737  }
9738 
9739  case 0xD2: // int 32
9740  {
9741  std::int32_t number{};
9742  return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9743  }
9744 
9745  case 0xD3: // int 64
9746  {
9747  std::int64_t number{};
9748  return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9749  }
9750 
9751  case 0xDC: // array 16
9752  {
9753  std::uint16_t len{};
9754  return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len));
9755  }
9756 
9757  case 0xDD: // array 32
9758  {
9759  std::uint32_t len{};
9760  return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len));
9761  }
9762 
9763  case 0xDE: // map 16
9764  {
9765  std::uint16_t len{};
9766  return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len));
9767  }
9768 
9769  case 0xDF: // map 32
9770  {
9771  std::uint32_t len{};
9772  return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len));
9773  }
9774 
9775  // negative fixint
9776  case 0xE0:
9777  case 0xE1:
9778  case 0xE2:
9779  case 0xE3:
9780  case 0xE4:
9781  case 0xE5:
9782  case 0xE6:
9783  case 0xE7:
9784  case 0xE8:
9785  case 0xE9:
9786  case 0xEA:
9787  case 0xEB:
9788  case 0xEC:
9789  case 0xED:
9790  case 0xEE:
9791  case 0xEF:
9792  case 0xF0:
9793  case 0xF1:
9794  case 0xF2:
9795  case 0xF3:
9796  case 0xF4:
9797  case 0xF5:
9798  case 0xF6:
9799  case 0xF7:
9800  case 0xF8:
9801  case 0xF9:
9802  case 0xFA:
9803  case 0xFB:
9804  case 0xFC:
9805  case 0xFD:
9806  case 0xFE:
9807  case 0xFF:
9808  return sax->number_integer(static_cast<std::int8_t>(current));
9809 
9810  default: // anything else
9811  {
9812  auto last_token = get_token_string();
9813  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
9814  }
9815  }
9816  }
9817 
9829  {
9831  {
9832  return false;
9833  }
9834 
9835  switch (current)
9836  {
9837  // fixstr
9838  case 0xA0:
9839  case 0xA1:
9840  case 0xA2:
9841  case 0xA3:
9842  case 0xA4:
9843  case 0xA5:
9844  case 0xA6:
9845  case 0xA7:
9846  case 0xA8:
9847  case 0xA9:
9848  case 0xAA:
9849  case 0xAB:
9850  case 0xAC:
9851  case 0xAD:
9852  case 0xAE:
9853  case 0xAF:
9854  case 0xB0:
9855  case 0xB1:
9856  case 0xB2:
9857  case 0xB3:
9858  case 0xB4:
9859  case 0xB5:
9860  case 0xB6:
9861  case 0xB7:
9862  case 0xB8:
9863  case 0xB9:
9864  case 0xBA:
9865  case 0xBB:
9866  case 0xBC:
9867  case 0xBD:
9868  case 0xBE:
9869  case 0xBF:
9870  {
9871  return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
9872  }
9873 
9874  case 0xD9: // str 8
9875  {
9876  std::uint8_t len{};
9878  }
9879 
9880  case 0xDA: // str 16
9881  {
9882  std::uint16_t len{};
9884  }
9885 
9886  case 0xDB: // str 32
9887  {
9888  std::uint32_t len{};
9890  }
9891 
9892  default:
9893  {
9894  auto last_token = get_token_string();
9895  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType()));
9896  }
9897  }
9898  }
9899 
9911  {
9912  // helper function to set the subtype
9913  auto assign_and_return_true = [&result](std::int8_t subtype)
9914  {
9915  result.set_subtype(static_cast<std::uint8_t>(subtype));
9916  return true;
9917  };
9918 
9919  switch (current)
9920  {
9921  case 0xC4: // bin 8
9922  {
9923  std::uint8_t len{};
9924  return get_number(input_format_t::msgpack, len) &&
9926  }
9927 
9928  case 0xC5: // bin 16
9929  {
9930  std::uint16_t len{};
9931  return get_number(input_format_t::msgpack, len) &&
9933  }
9934 
9935  case 0xC6: // bin 32
9936  {
9937  std::uint32_t len{};
9938  return get_number(input_format_t::msgpack, len) &&
9940  }
9941 
9942  case 0xC7: // ext 8
9943  {
9944  std::uint8_t len{};
9945  std::int8_t subtype{};
9946  return get_number(input_format_t::msgpack, len) &&
9947  get_number(input_format_t::msgpack, subtype) &&
9949  assign_and_return_true(subtype);
9950  }
9951 
9952  case 0xC8: // ext 16
9953  {
9954  std::uint16_t len{};
9955  std::int8_t subtype{};
9956  return get_number(input_format_t::msgpack, len) &&
9957  get_number(input_format_t::msgpack, subtype) &&
9959  assign_and_return_true(subtype);
9960  }
9961 
9962  case 0xC9: // ext 32
9963  {
9964  std::uint32_t len{};
9965  std::int8_t subtype{};
9966  return get_number(input_format_t::msgpack, len) &&
9967  get_number(input_format_t::msgpack, subtype) &&
9969  assign_and_return_true(subtype);
9970  }
9971 
9972  case 0xD4: // fixext 1
9973  {
9974  std::int8_t subtype{};
9975  return get_number(input_format_t::msgpack, subtype) &&
9977  assign_and_return_true(subtype);
9978  }
9979 
9980  case 0xD5: // fixext 2
9981  {
9982  std::int8_t subtype{};
9983  return get_number(input_format_t::msgpack, subtype) &&
9985  assign_and_return_true(subtype);
9986  }
9987 
9988  case 0xD6: // fixext 4
9989  {
9990  std::int8_t subtype{};
9991  return get_number(input_format_t::msgpack, subtype) &&
9993  assign_and_return_true(subtype);
9994  }
9995 
9996  case 0xD7: // fixext 8
9997  {
9998  std::int8_t subtype{};
9999  return get_number(input_format_t::msgpack, subtype) &&
10001  assign_and_return_true(subtype);
10002  }
10003 
10004  case 0xD8: // fixext 16
10005  {
10006  std::int8_t subtype{};
10007  return get_number(input_format_t::msgpack, subtype) &&
10009  assign_and_return_true(subtype);
10010  }
10011 
10012  default: // LCOV_EXCL_LINE
10013  return false; // LCOV_EXCL_LINE
10014  }
10015  }
10016 
10021  bool get_msgpack_array(const std::size_t len)
10022  {
10023  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
10024  {
10025  return false;
10026  }
10027 
10028  for (std::size_t i = 0; i < len; ++i)
10029  {
10031  {
10032  return false;
10033  }
10034  }
10035 
10036  return sax->end_array();
10037  }
10038 
10043  bool get_msgpack_object(const std::size_t len)
10044  {
10045  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
10046  {
10047  return false;
10048  }
10049 
10050  string_t key;
10051  for (std::size_t i = 0; i < len; ++i)
10052  {
10053  get();
10054  if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key)))
10055  {
10056  return false;
10057  }
10058 
10060  {
10061  return false;
10062  }
10063  key.clear();
10064  }
10065 
10066  return sax->end_object();
10067  }
10068 
10070  // UBJSON //
10072 
10080  bool parse_ubjson_internal(const bool get_char = true)
10081  {
10082  return get_ubjson_value(get_char ? get_ignore_noop() : current);
10083  }
10084 
10099  bool get_ubjson_string(string_t& result, const bool get_char = true)
10100  {
10101  if (get_char)
10102  {
10103  get(); // TODO(niels): may we ignore N here?
10104  }
10105 
10107  {
10108  return false;
10109  }
10110 
10111  switch (current)
10112  {
10113  case 'U':
10114  {
10115  std::uint8_t len{};
10117  }
10118 
10119  case 'i':
10120  {
10121  std::int8_t len{};
10123  }
10124 
10125  case 'I':
10126  {
10127  std::int16_t len{};
10129  }
10130 
10131  case 'l':
10132  {
10133  std::int32_t len{};
10135  }
10136 
10137  case 'L':
10138  {
10139  std::int64_t len{};
10141  }
10142 
10143  default:
10144  auto last_token = get_token_string();
10145  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType()));
10146  }
10147  }
10148 
10153  bool get_ubjson_size_value(std::size_t& result)
10154  {
10155  switch (get_ignore_noop())
10156  {
10157  case 'U':
10158  {
10159  std::uint8_t number{};
10161  {
10162  return false;
10163  }
10164  result = static_cast<std::size_t>(number);
10165  return true;
10166  }
10167 
10168  case 'i':
10169  {
10170  std::int8_t number{};
10172  {
10173  return false;
10174  }
10175  result = static_cast<std::size_t>(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char
10176  return true;
10177  }
10178 
10179  case 'I':
10180  {
10181  std::int16_t number{};
10183  {
10184  return false;
10185  }
10186  result = static_cast<std::size_t>(number);
10187  return true;
10188  }
10189 
10190  case 'l':
10191  {
10192  std::int32_t number{};
10194  {
10195  return false;
10196  }
10197  result = static_cast<std::size_t>(number);
10198  return true;
10199  }
10200 
10201  case 'L':
10202  {
10203  std::int64_t number{};
10205  {
10206  return false;
10207  }
10208  result = static_cast<std::size_t>(number);
10209  return true;
10210  }
10211 
10212  default:
10213  {
10214  auto last_token = get_token_string();
10215  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType()));
10216  }
10217  }
10218  }
10219 
10230  bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
10231  {
10232  result.first = string_t::npos; // size
10233  result.second = 0; // type
10234 
10235  get_ignore_noop();
10236 
10237  if (current == '$')
10238  {
10239  result.second = get(); // must not ignore 'N', because 'N' maybe the type
10241  {
10242  return false;
10243  }
10244 
10245  get_ignore_noop();
10246  if (JSON_HEDLEY_UNLIKELY(current != '#'))
10247  {
10249  {
10250  return false;
10251  }
10252  auto last_token = get_token_string();
10253  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType()));
10254  }
10255 
10256  return get_ubjson_size_value(result.first);
10257  }
10258 
10259  if (current == '#')
10260  {
10261  return get_ubjson_size_value(result.first);
10262  }
10263 
10264  return true;
10265  }
10266 
10272  {
10273  switch (prefix)
10274  {
10275  case std::char_traits<char_type>::eof(): // EOF
10276  return unexpect_eof(input_format_t::ubjson, "value");
10277 
10278  case 'T': // true
10279  return sax->boolean(true);
10280  case 'F': // false
10281  return sax->boolean(false);
10282 
10283  case 'Z': // null
10284  return sax->null();
10285 
10286  case 'U':
10287  {
10288  std::uint8_t number{};
10289  return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number);
10290  }
10291 
10292  case 'i':
10293  {
10294  std::int8_t number{};
10295  return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
10296  }
10297 
10298  case 'I':
10299  {
10300  std::int16_t number{};
10301  return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
10302  }
10303 
10304  case 'l':
10305  {
10306  std::int32_t number{};
10307  return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
10308  }
10309 
10310  case 'L':
10311  {
10312  std::int64_t number{};
10313  return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
10314  }
10315 
10316  case 'd':
10317  {
10318  float number{};
10319  return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number), "");
10320  }
10321 
10322  case 'D':
10323  {
10324  double number{};
10325  return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number), "");
10326  }
10327 
10328  case 'H':
10329  {
10331  }
10332 
10333  case 'C': // char
10334  {
10335  get();
10337  {
10338  return false;
10339  }
10340  if (JSON_HEDLEY_UNLIKELY(current > 127))
10341  {
10342  auto last_token = get_token_string();
10343  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType()));
10344  }
10345  string_t s(1, static_cast<typename string_t::value_type>(current));
10346  return sax->string(s);
10347  }
10348 
10349  case 'S': // string
10350  {
10351  string_t s;
10352  return get_ubjson_string(s) && sax->string(s);
10353  }
10354 
10355  case '[': // array
10356  return get_ubjson_array();
10357 
10358  case '{': // object
10359  return get_ubjson_object();
10360 
10361  default: // anything else
10362  {
10363  auto last_token = get_token_string();
10364  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
10365  }
10366  }
10367  }
10368 
10373  {
10374  std::pair<std::size_t, char_int_type> size_and_type;
10375  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
10376  {
10377  return false;
10378  }
10379 
10380  if (size_and_type.first != string_t::npos)
10381  {
10382  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
10383  {
10384  return false;
10385  }
10386 
10387  if (size_and_type.second != 0)
10388  {
10389  if (size_and_type.second != 'N')
10390  {
10391  for (std::size_t i = 0; i < size_and_type.first; ++i)
10392  {
10393  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
10394  {
10395  return false;
10396  }
10397  }
10398  }
10399  }
10400  else
10401  {
10402  for (std::size_t i = 0; i < size_and_type.first; ++i)
10403  {
10405  {
10406  return false;
10407  }
10408  }
10409  }
10410  }
10411  else
10412  {
10413  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
10414  {
10415  return false;
10416  }
10417 
10418  while (current != ']')
10419  {
10421  {
10422  return false;
10423  }
10424  get_ignore_noop();
10425  }
10426  }
10427 
10428  return sax->end_array();
10429  }
10430 
10435  {
10436  std::pair<std::size_t, char_int_type> size_and_type;
10437  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
10438  {
10439  return false;
10440  }
10441 
10442  string_t key;
10443  if (size_and_type.first != string_t::npos)
10444  {
10445  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
10446  {
10447  return false;
10448  }
10449 
10450  if (size_and_type.second != 0)
10451  {
10452  for (std::size_t i = 0; i < size_and_type.first; ++i)
10453  {
10454  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
10455  {
10456  return false;
10457  }
10458  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
10459  {
10460  return false;
10461  }
10462  key.clear();
10463  }
10464  }
10465  else
10466  {
10467  for (std::size_t i = 0; i < size_and_type.first; ++i)
10468  {
10469  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
10470  {
10471  return false;
10472  }
10474  {
10475  return false;
10476  }
10477  key.clear();
10478  }
10479  }
10480  }
10481  else
10482  {
10483  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
10484  {
10485  return false;
10486  }
10487 
10488  while (current != '}')
10489  {
10490  if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key)))
10491  {
10492  return false;
10493  }
10495  {
10496  return false;
10497  }
10498  get_ignore_noop();
10499  key.clear();
10500  }
10501  }
10502 
10503  return sax->end_object();
10504  }
10505 
10506  // Note, no reader for UBJSON binary types is implemented because they do
10507  // not exist
10508 
10510  {
10511  // get size of following number string
10512  std::size_t size{};
10513  auto res = get_ubjson_size_value(size);
10514  if (JSON_HEDLEY_UNLIKELY(!res))
10515  {
10516  return res;
10517  }
10518 
10519  // get number string
10520  std::vector<char> number_vector;
10521  for (std::size_t i = 0; i < size; ++i)
10522  {
10523  get();
10525  {
10526  return false;
10527  }
10528  number_vector.push_back(static_cast<char>(current));
10529  }
10530 
10531  // parse number string
10532  using ia_type = decltype(detail::input_adapter(number_vector));
10533  auto number_lexer = detail::lexer<BasicJsonType, ia_type>(detail::input_adapter(number_vector), false);
10534  const auto result_number = number_lexer.scan();
10535  const auto number_string = number_lexer.get_token_string();
10536  const auto result_remainder = number_lexer.scan();
10537 
10538  using token_type = typename detail::lexer_base<BasicJsonType>::token_type;
10539 
10540  if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input))
10541  {
10542  return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType()));
10543  }
10544 
10545  switch (result_number)
10546  {
10547  case token_type::value_integer:
10548  return sax->number_integer(number_lexer.get_number_integer());
10549  case token_type::value_unsigned:
10550  return sax->number_unsigned(number_lexer.get_number_unsigned());
10551  case token_type::value_float:
10552  return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
10553  case token_type::uninitialized:
10554  case token_type::literal_true:
10555  case token_type::literal_false:
10556  case token_type::literal_null:
10557  case token_type::value_string:
10558  case token_type::begin_array:
10559  case token_type::begin_object:
10560  case token_type::end_array:
10561  case token_type::end_object:
10562  case token_type::name_separator:
10563  case token_type::value_separator:
10564  case token_type::parse_error:
10565  case token_type::end_of_input:
10566  case token_type::literal_or_value:
10567  default:
10568  return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType()));
10569  }
10570  }
10571 
10573  // Utility functions //
10575 
10586  {
10587  ++chars_read;
10588  return current = ia.get_character();
10589  }
10590 
10595  {
10596  do
10597  {
10598  get();
10599  }
10600  while (current == 'N');
10601 
10602  return current;
10603  }
10604 
10605  /*
10606  @brief read a number from the input
10607 
10608  @tparam NumberType the type of the number
10609  @param[in] format the current format (for diagnostics)
10610  @param[out] result number of type @a NumberType
10611 
10612  @return whether conversion completed
10613 
10614  @note This function needs to respect the system's endianess, because
10615  bytes in CBOR, MessagePack, and UBJSON are stored in network order
10616  (big endian) and therefore need reordering on little endian systems.
10617  */
10618  template<typename NumberType, bool InputIsLittleEndian = false>
10619  bool get_number(const input_format_t format, NumberType& result)
10620  {
10621  // step 1: read input into array with system's byte order
10622  std::array<std::uint8_t, sizeof(NumberType)> vec{};
10623  for (std::size_t i = 0; i < sizeof(NumberType); ++i)
10624  {
10625  get();
10626  if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number")))
10627  {
10628  return false;
10629  }
10630 
10631  // reverse byte order prior to conversion if necessary
10632  if (is_little_endian != InputIsLittleEndian)
10633  {
10634  vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
10635  }
10636  else
10637  {
10638  vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
10639  }
10640  }
10641 
10642  // step 2: convert array into number of type T and return
10643  std::memcpy(&result, vec.data(), sizeof(NumberType));
10644  return true;
10645  }
10646 
10661  template<typename NumberType>
10662  bool get_string(const input_format_t format,
10663  const NumberType len,
10664  string_t& result)
10665  {
10666  bool success = true;
10667  for (NumberType i = 0; i < len; i++)
10668  {
10669  get();
10670  if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string")))
10671  {
10672  success = false;
10673  break;
10674  }
10675  result.push_back(static_cast<typename string_t::value_type>(current));
10676  }
10677  return success;
10678  }
10679 
10694  template<typename NumberType>
10695  bool get_binary(const input_format_t format,
10696  const NumberType len,
10697  binary_t& result)
10698  {
10699  bool success = true;
10700  for (NumberType i = 0; i < len; i++)
10701  {
10702  get();
10703  if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary")))
10704  {
10705  success = false;
10706  break;
10707  }
10708  result.push_back(static_cast<std::uint8_t>(current));
10709  }
10710  return success;
10711  }
10712 
10719  bool unexpect_eof(const input_format_t format, const char* context) const
10720  {
10721  if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
10722  {
10723  return sax->parse_error(chars_read, "<end of file>",
10724  parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType()));
10725  }
10726  return true;
10727  }
10728 
10732  std::string get_token_string() const
10733  {
10734  std::array<char, 3> cr{{}};
10735  (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
10736  return std::string{cr.data()};
10737  }
10738 
10745  std::string exception_message(const input_format_t format,
10746  const std::string& detail,
10747  const std::string& context) const
10748  {
10749  std::string error_msg = "syntax error while parsing ";
10750 
10751  switch (format)
10752  {
10753  case input_format_t::cbor:
10754  error_msg += "CBOR";
10755  break;
10756 
10758  error_msg += "MessagePack";
10759  break;
10760 
10762  error_msg += "UBJSON";
10763  break;
10764 
10765  case input_format_t::bson:
10766  error_msg += "BSON";
10767  break;
10768 
10769  case input_format_t::json: // LCOV_EXCL_LINE
10770  default: // LCOV_EXCL_LINE
10771  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
10772  }
10773 
10774  return error_msg + " " + context + ": " + detail;
10775  }
10776 
10777  private:
10779  InputAdapterType ia;
10780 
10782  char_int_type current = std::char_traits<char_type>::eof();
10783 
10785  std::size_t chars_read = 0;
10786 
10789 
10791  json_sax_t* sax = nullptr;
10792 };
10793 } // namespace detail
10794 } // namespace nlohmann
10795 
10796 // #include <nlohmann/detail/input/input_adapters.hpp>
10797 
10798 // #include <nlohmann/detail/input/lexer.hpp>
10799 
10800 // #include <nlohmann/detail/input/parser.hpp>
10801 
10802 
10803 #include <cmath> // isfinite
10804 #include <cstdint> // uint8_t
10805 #include <functional> // function
10806 #include <string> // string
10807 #include <utility> // move
10808 #include <vector> // vector
10809 
10810 // #include <nlohmann/detail/exceptions.hpp>
10811 
10812 // #include <nlohmann/detail/input/input_adapters.hpp>
10813 
10814 // #include <nlohmann/detail/input/json_sax.hpp>
10815 
10816 // #include <nlohmann/detail/input/lexer.hpp>
10817 
10818 // #include <nlohmann/detail/macro_scope.hpp>
10819 
10820 // #include <nlohmann/detail/meta/is_sax.hpp>
10821 
10822 // #include <nlohmann/detail/value_t.hpp>
10823 
10824 
10825 namespace nlohmann
10826 {
10827 namespace detail
10828 {
10830 // parser //
10832 
10833 enum class parse_event_t : std::uint8_t
10834 {
10836  object_start,
10838  object_end,
10840  array_start,
10842  array_end,
10844  key,
10846  value
10847 };
10848 
10849 template<typename BasicJsonType>
10850 using parser_callback_t =
10851  std::function<bool(int /*depth*/, parse_event_t /*event*/, BasicJsonType& /*parsed*/)>;
10852 
10858 template<typename BasicJsonType, typename InputAdapterType>
10859 class parser
10860 {
10861  using number_integer_t = typename BasicJsonType::number_integer_t;
10862  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
10863  using number_float_t = typename BasicJsonType::number_float_t;
10864  using string_t = typename BasicJsonType::string_t;
10867 
10868  public:
10870  explicit parser(InputAdapterType&& adapter,
10871  const parser_callback_t<BasicJsonType> cb = nullptr,
10872  const bool allow_exceptions_ = true,
10873  const bool skip_comments = false)
10874  : callback(cb)
10875  , m_lexer(std::move(adapter), skip_comments)
10876  , allow_exceptions(allow_exceptions_)
10877  {
10878  // read first token
10879  get_token();
10880  }
10881 
10892  void parse(const bool strict, BasicJsonType& result)
10893  {
10894  if (callback)
10895  {
10897  sax_parse_internal(&sdp);
10898 
10899  // in strict mode, input must be completely read
10900  if (strict && (get_token() != token_type::end_of_input))
10901  {
10905  exception_message(token_type::end_of_input, "value"), BasicJsonType()));
10906  }
10907 
10908  // in case of an error, return discarded value
10909  if (sdp.is_errored())
10910  {
10912  return;
10913  }
10914 
10915  // set top-level value to null if it was discarded by the callback
10916  // function
10917  if (result.is_discarded())
10918  {
10919  result = nullptr;
10920  }
10921  }
10922  else
10923  {
10925  sax_parse_internal(&sdp);
10926 
10927  // in strict mode, input must be completely read
10928  if (strict && (get_token() != token_type::end_of_input))
10929  {
10932  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType()));
10933  }
10934 
10935  // in case of an error, return discarded value
10936  if (sdp.is_errored())
10937  {
10939  return;
10940  }
10941  }
10942 
10943  result.assert_invariant();
10944  }
10945 
10952  bool accept(const bool strict = true)
10953  {
10954  json_sax_acceptor<BasicJsonType> sax_acceptor;
10955  return sax_parse(&sax_acceptor, strict);
10956  }
10957 
10958  template<typename SAX>
10960  bool sax_parse(SAX* sax, const bool strict = true)
10961  {
10963  const bool result = sax_parse_internal(sax);
10964 
10965  // strict mode: next byte must be EOF
10966  if (result && strict && (get_token() != token_type::end_of_input))
10967  {
10968  return sax->parse_error(m_lexer.get_position(),
10970  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType()));
10971  }
10972 
10973  return result;
10974  }
10975 
10976  private:
10977  template<typename SAX>
10979  bool sax_parse_internal(SAX* sax)
10980  {
10981  // stack to remember the hierarchy of structured values we are parsing
10982  // true = array; false = object
10983  std::vector<bool> states;
10984  // value to avoid a goto (see comment where set to true)
10985  bool skip_to_state_evaluation = false;
10986 
10987  while (true)
10988  {
10989  if (!skip_to_state_evaluation)
10990  {
10991  // invariant: get_token() was called before each iteration
10992  switch (last_token)
10993  {
10994  case token_type::begin_object:
10995  {
10996  if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
10997  {
10998  return false;
10999  }
11000 
11001  // closing } -> we are done
11002  if (get_token() == token_type::end_object)
11003  {
11004  if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
11005  {
11006  return false;
11007  }
11008  break;
11009  }
11010 
11011  // parse key
11012  if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string))
11013  {
11014  return sax->parse_error(m_lexer.get_position(),
11016  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType()));
11017  }
11018  if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
11019  {
11020  return false;
11021  }
11022 
11023  // parse separator (:)
11024  if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
11025  {
11026  return sax->parse_error(m_lexer.get_position(),
11028  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType()));
11029  }
11030 
11031  // remember we are now inside an object
11032  states.push_back(false);
11033 
11034  // parse values
11035  get_token();
11036  continue;
11037  }
11038 
11039  case token_type::begin_array:
11040  {
11041  if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
11042  {
11043  return false;
11044  }
11045 
11046  // closing ] -> we are done
11047  if (get_token() == token_type::end_array)
11048  {
11049  if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
11050  {
11051  return false;
11052  }
11053  break;
11054  }
11055 
11056  // remember we are now inside an array
11057  states.push_back(true);
11058 
11059  // parse values (no need to call get_token)
11060  continue;
11061  }
11062 
11063  case token_type::value_float:
11064  {
11065  const auto res = m_lexer.get_number_float();
11066 
11067  if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res)))
11068  {
11069  return sax->parse_error(m_lexer.get_position(),
11071  out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType()));
11072  }
11073 
11074  if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string())))
11075  {
11076  return false;
11077  }
11078 
11079  break;
11080  }
11081 
11082  case token_type::literal_false:
11083  {
11084  if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false)))
11085  {
11086  return false;
11087  }
11088  break;
11089  }
11090 
11091  case token_type::literal_null:
11092  {
11093  if (JSON_HEDLEY_UNLIKELY(!sax->null()))
11094  {
11095  return false;
11096  }
11097  break;
11098  }
11099 
11100  case token_type::literal_true:
11101  {
11102  if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true)))
11103  {
11104  return false;
11105  }
11106  break;
11107  }
11108 
11109  case token_type::value_integer:
11110  {
11111  if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer())))
11112  {
11113  return false;
11114  }
11115  break;
11116  }
11117 
11118  case token_type::value_string:
11119  {
11120  if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string())))
11121  {
11122  return false;
11123  }
11124  break;
11125  }
11126 
11127  case token_type::value_unsigned:
11128  {
11129  if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned())))
11130  {
11131  return false;
11132  }
11133  break;
11134  }
11135 
11136  case token_type::parse_error:
11137  {
11138  // using "uninitialized" to avoid "expected" message
11139  return sax->parse_error(m_lexer.get_position(),
11141  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType()));
11142  }
11143 
11144  case token_type::uninitialized:
11145  case token_type::end_array:
11146  case token_type::end_object:
11147  case token_type::name_separator:
11148  case token_type::value_separator:
11149  case token_type::end_of_input:
11150  case token_type::literal_or_value:
11151  default: // the last token was unexpected
11152  {
11153  return sax->parse_error(m_lexer.get_position(),
11155  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType()));
11156  }
11157  }
11158  }
11159  else
11160  {
11161  skip_to_state_evaluation = false;
11162  }
11163 
11164  // we reached this line after we successfully parsed a value
11165  if (states.empty())
11166  {
11167  // empty stack: we reached the end of the hierarchy: done
11168  return true;
11169  }
11170 
11171  if (states.back()) // array
11172  {
11173  // comma -> next value
11174  if (get_token() == token_type::value_separator)
11175  {
11176  // parse a new value
11177  get_token();
11178  continue;
11179  }
11180 
11181  // closing ]
11182  if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array))
11183  {
11184  if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
11185  {
11186  return false;
11187  }
11188 
11189  // We are done with this array. Before we can parse a
11190  // new value, we need to evaluate the new state first.
11191  // By setting skip_to_state_evaluation to false, we
11192  // are effectively jumping to the beginning of this if.
11193  JSON_ASSERT(!states.empty());
11194  states.pop_back();
11195  skip_to_state_evaluation = true;
11196  continue;
11197  }
11198 
11199  return sax->parse_error(m_lexer.get_position(),
11201  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType()));
11202  }
11203 
11204  // states.back() is false -> object
11205 
11206  // comma -> next value
11207  if (get_token() == token_type::value_separator)
11208  {
11209  // parse key
11210  if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string))
11211  {
11212  return sax->parse_error(m_lexer.get_position(),
11214  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType()));
11215  }
11216 
11217  if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
11218  {
11219  return false;
11220  }
11221 
11222  // parse separator (:)
11223  if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
11224  {
11225  return sax->parse_error(m_lexer.get_position(),
11227  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType()));
11228  }
11229 
11230  // parse values
11231  get_token();
11232  continue;
11233  }
11234 
11235  // closing }
11236  if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
11237  {
11238  if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
11239  {
11240  return false;
11241  }
11242 
11243  // We are done with this object. Before we can parse a
11244  // new value, we need to evaluate the new state first.
11245  // By setting skip_to_state_evaluation to false, we
11246  // are effectively jumping to the beginning of this if.
11247  JSON_ASSERT(!states.empty());
11248  states.pop_back();
11249  skip_to_state_evaluation = true;
11250  continue;
11251  }
11252 
11253  return sax->parse_error(m_lexer.get_position(),
11255  parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType()));
11256  }
11257  }
11258 
11261  {
11262  return last_token = m_lexer.scan();
11263  }
11264 
11265  std::string exception_message(const token_type expected, const std::string& context)
11266  {
11267  std::string error_msg = "syntax error ";
11268 
11269  if (!context.empty())
11270  {
11271  error_msg += "while parsing " + context + " ";
11272  }
11273 
11274  error_msg += "- ";
11275 
11276  if (last_token == token_type::parse_error)
11277  {
11278  error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" +
11279  m_lexer.get_token_string() + "'";
11280  }
11281  else
11282  {
11283  error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token));
11284  }
11285 
11286  if (expected != token_type::uninitialized)
11287  {
11288  error_msg += "; expected " + std::string(lexer_t::token_type_name(expected));
11289  }
11290 
11291  return error_msg;
11292  }
11293 
11294  private:
11298  token_type last_token = token_type::uninitialized;
11302  const bool allow_exceptions = true;
11303 };
11304 
11305 } // namespace detail
11306 } // namespace nlohmann
11307 
11308 // #include <nlohmann/detail/iterators/internal_iterator.hpp>
11309 
11310 
11311 // #include <nlohmann/detail/iterators/primitive_iterator.hpp>
11312 
11313 
11314 #include <cstddef> // ptrdiff_t
11315 #include <limits> // numeric_limits
11316 
11317 // #include <nlohmann/detail/macro_scope.hpp>
11318 
11319 
11320 namespace nlohmann
11321 {
11322 namespace detail
11323 {
11324 /*
11325 @brief an iterator for primitive JSON types
11326 
11327 This class models an iterator for primitive JSON types (boolean, number,
11328 string). It's only purpose is to allow the iterator/const_iterator classes
11329 to "iterate" over primitive values. Internally, the iterator is modeled by
11330 a `difference_type` variable. Value begin_value (`0`) models the begin,
11331 end_value (`1`) models past the end.
11332 */
11334 {
11335  private:
11336  using difference_type = std::ptrdiff_t;
11337  static constexpr difference_type begin_value = 0;
11338  static constexpr difference_type end_value = begin_value + 1;
11339 
11342  difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
11343 
11344  public:
11345  constexpr difference_type get_value() const noexcept
11346  {
11347  return m_it;
11348  }
11349 
11351  void set_begin() noexcept
11352  {
11353  m_it = begin_value;
11354  }
11355 
11357  void set_end() noexcept
11358  {
11359  m_it = end_value;
11360  }
11361 
11363  constexpr bool is_begin() const noexcept
11364  {
11365  return m_it == begin_value;
11366  }
11367 
11369  constexpr bool is_end() const noexcept
11370  {
11371  return m_it == end_value;
11372  }
11373 
11374  friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
11375  {
11376  return lhs.m_it == rhs.m_it;
11377  }
11378 
11379  friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
11380  {
11381  return lhs.m_it < rhs.m_it;
11382  }
11383 
11385  {
11386  auto result = *this;
11387  result += n;
11388  return result;
11389  }
11390 
11392  {
11393  return lhs.m_it - rhs.m_it;
11394  }
11395 
11397  {
11398  ++m_it;
11399  return *this;
11400  }
11401 
11402  primitive_iterator_t const operator++(int) noexcept // NOLINT(readability-const-return-type)
11403  {
11404  auto result = *this;
11405  ++m_it;
11406  return result;
11407  }
11408 
11410  {
11411  --m_it;
11412  return *this;
11413  }
11414 
11415  primitive_iterator_t const operator--(int) noexcept // NOLINT(readability-const-return-type)
11416  {
11417  auto result = *this;
11418  --m_it;
11419  return result;
11420  }
11421 
11423  {
11424  m_it += n;
11425  return *this;
11426  }
11427 
11429  {
11430  m_it -= n;
11431  return *this;
11432  }
11433 };
11434 } // namespace detail
11435 } // namespace nlohmann
11436 
11437 
11438 namespace nlohmann
11439 {
11440 namespace detail
11441 {
11448 template<typename BasicJsonType> struct internal_iterator
11449 {
11451  typename BasicJsonType::object_t::iterator object_iterator {};
11453  typename BasicJsonType::array_t::iterator array_iterator {};
11456 };
11457 } // namespace detail
11458 } // namespace nlohmann
11459 
11460 // #include <nlohmann/detail/iterators/iter_impl.hpp>
11461 
11462 
11463 #include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
11464 #include <type_traits> // conditional, is_const, remove_const
11465 
11466 // #include <nlohmann/detail/exceptions.hpp>
11467 
11468 // #include <nlohmann/detail/iterators/internal_iterator.hpp>
11469 
11470 // #include <nlohmann/detail/iterators/primitive_iterator.hpp>
11471 
11472 // #include <nlohmann/detail/macro_scope.hpp>
11473 
11474 // #include <nlohmann/detail/meta/cpp_future.hpp>
11475 
11476 // #include <nlohmann/detail/meta/type_traits.hpp>
11477 
11478 // #include <nlohmann/detail/value_t.hpp>
11479 
11480 
11481 namespace nlohmann
11482 {
11483 namespace detail
11484 {
11485 // forward declare, to be able to friend it later on
11486 template<typename IteratorType> class iteration_proxy;
11487 template<typename IteratorType> class iteration_proxy_value;
11488 
11505 template<typename BasicJsonType>
11507 {
11515 
11516  using object_t = typename BasicJsonType::object_t;
11517  using array_t = typename BasicJsonType::array_t;
11518  // make sure BasicJsonType is basic_json or const basic_json
11520  "iter_impl only accepts (const) basic_json");
11521 
11522  public:
11523 
11529  using iterator_category = std::bidirectional_iterator_tag;
11530 
11532  using value_type = typename BasicJsonType::value_type;
11534  using difference_type = typename BasicJsonType::difference_type;
11537  typename BasicJsonType::const_pointer,
11538  typename BasicJsonType::pointer>::type;
11540  using reference =
11542  typename BasicJsonType::const_reference,
11543  typename BasicJsonType::reference>::type;
11544 
11545  iter_impl() = default;
11546  ~iter_impl() = default;
11547  iter_impl(iter_impl&&) noexcept = default;
11548  iter_impl& operator=(iter_impl&&) noexcept = default;
11549 
11556  explicit iter_impl(pointer object) noexcept : m_object(object)
11557  {
11558  JSON_ASSERT(m_object != nullptr);
11559 
11560  switch (m_object->m_type)
11561  {
11562  case value_t::object:
11563  {
11564  m_it.object_iterator = typename object_t::iterator();
11565  break;
11566  }
11567 
11568  case value_t::array:
11569  {
11570  m_it.array_iterator = typename array_t::iterator();
11571  break;
11572  }
11573 
11574  case value_t::null:
11575  case value_t::string:
11576  case value_t::boolean:
11579  case value_t::number_float:
11580  case value_t::binary:
11581  case value_t::discarded:
11582  default:
11583  {
11585  break;
11586  }
11587  }
11588  }
11589 
11607  : m_object(other.m_object), m_it(other.m_it)
11608  {}
11609 
11617  {
11618  if (&other != this)
11619  {
11620  m_object = other.m_object;
11621  m_it = other.m_it;
11622  }
11623  return *this;
11624  }
11625 
11632  : m_object(other.m_object), m_it(other.m_it)
11633  {}
11634 
11641  iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept // NOLINT(cert-oop54-cpp)
11642  {
11643  m_object = other.m_object;
11644  m_it = other.m_it;
11645  return *this;
11646  }
11647 
11653  void set_begin() noexcept
11654  {
11655  JSON_ASSERT(m_object != nullptr);
11656 
11657  switch (m_object->m_type)
11658  {
11659  case value_t::object:
11660  {
11661  m_it.object_iterator = m_object->m_value.object->begin();
11662  break;
11663  }
11664 
11665  case value_t::array:
11666  {
11667  m_it.array_iterator = m_object->m_value.array->begin();
11668  break;
11669  }
11670 
11671  case value_t::null:
11672  {
11673  // set to end so begin()==end() is true: null is empty
11675  break;
11676  }
11677 
11678  case value_t::string:
11679  case value_t::boolean:
11682  case value_t::number_float:
11683  case value_t::binary:
11684  case value_t::discarded:
11685  default:
11686  {
11688  break;
11689  }
11690  }
11691  }
11692 
11697  void set_end() noexcept
11698  {
11699  JSON_ASSERT(m_object != nullptr);
11700 
11701  switch (m_object->m_type)
11702  {
11703  case value_t::object:
11704  {
11705  m_it.object_iterator = m_object->m_value.object->end();
11706  break;
11707  }
11708 
11709  case value_t::array:
11710  {
11711  m_it.array_iterator = m_object->m_value.array->end();
11712  break;
11713  }
11714 
11715  case value_t::null:
11716  case value_t::string:
11717  case value_t::boolean:
11720  case value_t::number_float:
11721  case value_t::binary:
11722  case value_t::discarded:
11723  default:
11724  {
11726  break;
11727  }
11728  }
11729  }
11730 
11731  public:
11737  {
11738  JSON_ASSERT(m_object != nullptr);
11739 
11740  switch (m_object->m_type)
11741  {
11742  case value_t::object:
11743  {
11744  JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11745  return m_it.object_iterator->second;
11746  }
11747 
11748  case value_t::array:
11749  {
11750  JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11751  return *m_it.array_iterator;
11752  }
11753 
11754  case value_t::null:
11755  JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
11756 
11757  case value_t::string:
11758  case value_t::boolean:
11761  case value_t::number_float:
11762  case value_t::binary:
11763  case value_t::discarded:
11764  default:
11765  {
11767  {
11768  return *m_object;
11769  }
11770 
11771  JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
11772  }
11773  }
11774  }
11775 
11781  {
11782  JSON_ASSERT(m_object != nullptr);
11783 
11784  switch (m_object->m_type)
11785  {
11786  case value_t::object:
11787  {
11788  JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11789  return &(m_it.object_iterator->second);
11790  }
11791 
11792  case value_t::array:
11793  {
11794  JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11795  return &*m_it.array_iterator;
11796  }
11797 
11798  case value_t::null:
11799  case value_t::string:
11800  case value_t::boolean:
11803  case value_t::number_float:
11804  case value_t::binary:
11805  case value_t::discarded:
11806  default:
11807  {
11809  {
11810  return m_object;
11811  }
11812 
11813  JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
11814  }
11815  }
11816  }
11817 
11822  iter_impl const operator++(int) // NOLINT(readability-const-return-type)
11823  {
11824  auto result = *this;
11825  ++(*this);
11826  return result;
11827  }
11828 
11834  {
11835  JSON_ASSERT(m_object != nullptr);
11836 
11837  switch (m_object->m_type)
11838  {
11839  case value_t::object:
11840  {
11841  std::advance(m_it.object_iterator, 1);
11842  break;
11843  }
11844 
11845  case value_t::array:
11846  {
11847  std::advance(m_it.array_iterator, 1);
11848  break;
11849  }
11850 
11851  case value_t::null:
11852  case value_t::string:
11853  case value_t::boolean:
11856  case value_t::number_float:
11857  case value_t::binary:
11858  case value_t::discarded:
11859  default:
11860  {
11862  break;
11863  }
11864  }
11865 
11866  return *this;
11867  }
11868 
11873  iter_impl const operator--(int) // NOLINT(readability-const-return-type)
11874  {
11875  auto result = *this;
11876  --(*this);
11877  return result;
11878  }
11879 
11885  {
11886  JSON_ASSERT(m_object != nullptr);
11887 
11888  switch (m_object->m_type)
11889  {
11890  case value_t::object:
11891  {
11892  std::advance(m_it.object_iterator, -1);
11893  break;
11894  }
11895 
11896  case value_t::array:
11897  {
11898  std::advance(m_it.array_iterator, -1);
11899  break;
11900  }
11901 
11902  case value_t::null:
11903  case value_t::string:
11904  case value_t::boolean:
11907  case value_t::number_float:
11908  case value_t::binary:
11909  case value_t::discarded:
11910  default:
11911  {
11913  break;
11914  }
11915  }
11916 
11917  return *this;
11918  }
11919 
11924  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 >
11925  bool operator==(const IterImpl& other) const
11926  {
11927  // if objects are not the same, the comparison is undefined
11928  if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
11929  {
11930  JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object));
11931  }
11932 
11933  JSON_ASSERT(m_object != nullptr);
11934 
11935  switch (m_object->m_type)
11936  {
11937  case value_t::object:
11938  return (m_it.object_iterator == other.m_it.object_iterator);
11939 
11940  case value_t::array:
11941  return (m_it.array_iterator == other.m_it.array_iterator);
11942 
11943  case value_t::null:
11944  case value_t::string:
11945  case value_t::boolean:
11948  case value_t::number_float:
11949  case value_t::binary:
11950  case value_t::discarded:
11951  default:
11952  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
11953  }
11954  }
11955 
11960  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 >
11961  bool operator!=(const IterImpl& other) const
11962  {
11963  return !operator==(other);
11964  }
11965 
11970  bool operator<(const iter_impl& other) const
11971  {
11972  // if objects are not the same, the comparison is undefined
11973  if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
11974  {
11975  JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object));
11976  }
11977 
11978  JSON_ASSERT(m_object != nullptr);
11979 
11980  switch (m_object->m_type)
11981  {
11982  case value_t::object:
11983  JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object));
11984 
11985  case value_t::array:
11986  return (m_it.array_iterator < other.m_it.array_iterator);
11987 
11988  case value_t::null:
11989  case value_t::string:
11990  case value_t::boolean:
11993  case value_t::number_float:
11994  case value_t::binary:
11995  case value_t::discarded:
11996  default:
11998  }
11999  }
12000 
12005  bool operator<=(const iter_impl& other) const
12006  {
12007  return !other.operator < (*this);
12008  }
12009 
12014  bool operator>(const iter_impl& other) const
12015  {
12016  return !operator<=(other);
12017  }
12018 
12023  bool operator>=(const iter_impl& other) const
12024  {
12025  return !operator<(other);
12026  }
12027 
12033  {
12034  JSON_ASSERT(m_object != nullptr);
12035 
12036  switch (m_object->m_type)
12037  {
12038  case value_t::object:
12039  JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object));
12040 
12041  case value_t::array:
12042  {
12043  std::advance(m_it.array_iterator, i);
12044  break;
12045  }
12046 
12047  case value_t::null:
12048  case value_t::string:
12049  case value_t::boolean:
12052  case value_t::number_float:
12053  case value_t::binary:
12054  case value_t::discarded:
12055  default:
12056  {
12057  m_it.primitive_iterator += i;
12058  break;
12059  }
12060  }
12061 
12062  return *this;
12063  }
12064 
12070  {
12071  return operator+=(-i);
12072  }
12073 
12079  {
12080  auto result = *this;
12081  result += i;
12082  return result;
12083  }
12084 
12090  {
12091  auto result = it;
12092  result += i;
12093  return result;
12094  }
12095 
12101  {
12102  auto result = *this;
12103  result -= i;
12104  return result;
12105  }
12106 
12112  {
12113  JSON_ASSERT(m_object != nullptr);
12114 
12115  switch (m_object->m_type)
12116  {
12117  case value_t::object:
12118  JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object));
12119 
12120  case value_t::array:
12121  return m_it.array_iterator - other.m_it.array_iterator;
12122 
12123  case value_t::null:
12124  case value_t::string:
12125  case value_t::boolean:
12128  case value_t::number_float:
12129  case value_t::binary:
12130  case value_t::discarded:
12131  default:
12133  }
12134  }
12135 
12141  {
12142  JSON_ASSERT(m_object != nullptr);
12143 
12144  switch (m_object->m_type)
12145  {
12146  case value_t::object:
12147  JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object));
12148 
12149  case value_t::array:
12150  return *std::next(m_it.array_iterator, n);
12151 
12152  case value_t::null:
12153  JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
12154 
12155  case value_t::string:
12156  case value_t::boolean:
12159  case value_t::number_float:
12160  case value_t::binary:
12161  case value_t::discarded:
12162  default:
12163  {
12165  {
12166  return *m_object;
12167  }
12168 
12169  JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
12170  }
12171  }
12172  }
12173 
12178  const typename object_t::key_type& key() const
12179  {
12180  JSON_ASSERT(m_object != nullptr);
12181 
12182  if (JSON_HEDLEY_LIKELY(m_object->is_object()))
12183  {
12184  return m_it.object_iterator->first;
12185  }
12186 
12187  JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object));
12188  }
12189 
12195  {
12196  return operator*();
12197  }
12198 
12201  pointer m_object = nullptr;
12204 };
12205 } // namespace detail
12206 } // namespace nlohmann
12207 
12208 // #include <nlohmann/detail/iterators/iteration_proxy.hpp>
12209 
12210 // #include <nlohmann/detail/iterators/json_reverse_iterator.hpp>
12211 
12212 
12213 #include <cstddef> // ptrdiff_t
12214 #include <iterator> // reverse_iterator
12215 #include <utility> // declval
12216 
12217 namespace nlohmann
12218 {
12219 namespace detail
12220 {
12222 // reverse_iterator //
12224 
12243 template<typename Base>
12244 class json_reverse_iterator : public std::reverse_iterator<Base>
12245 {
12246  public:
12247  using difference_type = std::ptrdiff_t;
12249  using base_iterator = std::reverse_iterator<Base>;
12251  using reference = typename Base::reference;
12252 
12254  explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
12255  : base_iterator(it) {}
12256 
12258  explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}
12259 
12261  json_reverse_iterator const operator++(int) // NOLINT(readability-const-return-type)
12262  {
12263  return static_cast<json_reverse_iterator>(base_iterator::operator++(1));
12264  }
12265 
12268  {
12269  return static_cast<json_reverse_iterator&>(base_iterator::operator++());
12270  }
12271 
12273  json_reverse_iterator const operator--(int) // NOLINT(readability-const-return-type)
12274  {
12275  return static_cast<json_reverse_iterator>(base_iterator::operator--(1));
12276  }
12277 
12280  {
12281  return static_cast<json_reverse_iterator&>(base_iterator::operator--());
12282  }
12283 
12286  {
12287  return static_cast<json_reverse_iterator&>(base_iterator::operator+=(i));
12288  }
12289 
12292  {
12293  return static_cast<json_reverse_iterator>(base_iterator::operator+(i));
12294  }
12295 
12298  {
12299  return static_cast<json_reverse_iterator>(base_iterator::operator-(i));
12300  }
12301 
12304  {
12305  return base_iterator(*this) - base_iterator(other);
12306  }
12307 
12310  {
12311  return *(this->operator+(n));
12312  }
12313 
12315  auto key() const -> decltype(std::declval<Base>().key())
12316  {
12317  auto it = --this->base();
12318  return it.key();
12319  }
12320 
12323  {
12324  auto it = --this->base();
12325  return it.operator * ();
12326  }
12327 };
12328 } // namespace detail
12329 } // namespace nlohmann
12330 
12331 // #include <nlohmann/detail/iterators/primitive_iterator.hpp>
12332 
12333 // #include <nlohmann/detail/json_pointer.hpp>
12334 
12335 
12336 #include <algorithm> // all_of
12337 #include <cctype> // isdigit
12338 #include <limits> // max
12339 #include <numeric> // accumulate
12340 #include <string> // string
12341 #include <utility> // move
12342 #include <vector> // vector
12343 
12344 // #include <nlohmann/detail/exceptions.hpp>
12345 
12346 // #include <nlohmann/detail/macro_scope.hpp>
12347 
12348 // #include <nlohmann/detail/string_escape.hpp>
12349 
12350 // #include <nlohmann/detail/value_t.hpp>
12351 
12352 
12353 namespace nlohmann
12354 {
12355 template<typename BasicJsonType>
12356 class json_pointer
12357 {
12358  // allow basic_json to access private members
12360  friend class basic_json;
12361 
12362  public:
12384  explicit json_pointer(const std::string& s = "")
12385  : reference_tokens(split(s))
12386  {}
12387 
12402  std::string to_string() const
12403  {
12404  return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
12405  std::string{},
12406  [](const std::string & a, const std::string & b)
12407  {
12408  return a + "/" + detail::escape(b);
12409  });
12410  }
12411 
12413  operator std::string() const
12414  {
12415  return to_string();
12416  }
12417 
12435  {
12436  reference_tokens.insert(reference_tokens.end(),
12437  ptr.reference_tokens.begin(),
12438  ptr.reference_tokens.end());
12439  return *this;
12440  }
12441 
12459  {
12460  push_back(std::move(token));
12461  return *this;
12462  }
12463 
12480  json_pointer& operator/=(std::size_t array_idx)
12481  {
12482  return *this /= std::to_string(array_idx);
12483  }
12484 
12501  const json_pointer& rhs)
12502  {
12503  return json_pointer(lhs) /= rhs;
12504  }
12505 
12521  friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param)
12522  {
12523  return json_pointer(ptr) /= std::move(token);
12524  }
12525 
12541  friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx)
12542  {
12543  return json_pointer(ptr) /= array_idx;
12544  }
12545 
12560  {
12561  if (empty())
12562  {
12563  return *this;
12564  }
12565 
12566  json_pointer res = *this;
12567  res.pop_back();
12568  return res;
12569  }
12570 
12584  void pop_back()
12585  {
12586  if (JSON_HEDLEY_UNLIKELY(empty()))
12587  {
12588  JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
12589  }
12590 
12591  reference_tokens.pop_back();
12592  }
12593 
12608  const std::string& back() const
12609  {
12610  if (JSON_HEDLEY_UNLIKELY(empty()))
12611  {
12612  JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
12613  }
12614 
12615  return reference_tokens.back();
12616  }
12617 
12630  void push_back(const std::string& token)
12631  {
12632  reference_tokens.push_back(token);
12633  }
12634 
12636  void push_back(std::string&& token)
12637  {
12638  reference_tokens.push_back(std::move(token));
12639  }
12640 
12655  bool empty() const noexcept
12656  {
12657  return reference_tokens.empty();
12658  }
12659 
12660  private:
12671  static typename BasicJsonType::size_type array_index(const std::string& s)
12672  {
12673  using size_type = typename BasicJsonType::size_type;
12674 
12675  // error condition (cf. RFC 6901, Sect. 4)
12676  if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0'))
12677  {
12678  JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType()));
12679  }
12680 
12681  // error condition (cf. RFC 6901, Sect. 4)
12682  if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9')))
12683  {
12684  JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType()));
12685  }
12686 
12687  std::size_t processed_chars = 0;
12688  unsigned long long res = 0; // NOLINT(runtime/int)
12689  JSON_TRY
12690  {
12691  res = std::stoull(s, &processed_chars);
12692  }
12693  JSON_CATCH(std::out_of_range&)
12694  {
12695  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType()));
12696  }
12697 
12698  // check if the string was completely read
12699  if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
12700  {
12701  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType()));
12702  }
12703 
12704  // only triggered on special platforms (like 32bit), see also
12705  // https://github.com/nlohmann/json/pull/2203
12706  if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)())) // NOLINT(runtime/int)
12707  {
12708  JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE
12709  }
12710 
12711  return static_cast<size_type>(res);
12712  }
12713 
12715  json_pointer top() const
12716  {
12717  if (JSON_HEDLEY_UNLIKELY(empty()))
12718  {
12719  JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
12720  }
12721 
12724  return result;
12725  }
12726 
12727  private:
12737  {
12738  auto* result = &j;
12739 
12740  // in case no reference tokens exist, return a reference to the JSON value
12741  // j which will be overwritten by a primitive value
12742  for (const auto& reference_token : reference_tokens)
12743  {
12744  switch (result->type())
12745  {
12746  case detail::value_t::null:
12747  {
12748  if (reference_token == "0")
12749  {
12750  // start a new array if reference token is 0
12751  result = &result->operator[](0);
12752  }
12753  else
12754  {
12755  // start a new object otherwise
12756  result = &result->operator[](reference_token);
12757  }
12758  break;
12759  }
12760 
12762  {
12763  // create an entry in the object
12764  result = &result->operator[](reference_token);
12765  break;
12766  }
12767 
12769  {
12770  // create an entry in the array
12771  result = &result->operator[](array_index(reference_token));
12772  break;
12773  }
12774 
12775  /*
12776  The following code is only reached if there exists a reference
12777  token _and_ the current value is primitive. In this case, we have
12778  an error situation, because primitive values may only occur as
12779  single value; that is, with an empty list of reference tokens.
12780  */
12788  default:
12789  JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j));
12790  }
12791  }
12792 
12793  return *result;
12794  }
12795 
12816  {
12817  for (const auto& reference_token : reference_tokens)
12818  {
12819  // convert null values to arrays or objects before continuing
12820  if (ptr->is_null())
12821  {
12822  // check if reference token is a number
12823  const bool nums =
12824  std::all_of(reference_token.begin(), reference_token.end(),
12825  [](const unsigned char x)
12826  {
12827  return std::isdigit(x);
12828  });
12829 
12830  // change value to array for numbers or "-" or to object otherwise
12831  *ptr = (nums || reference_token == "-")
12834  }
12835 
12836  switch (ptr->type())
12837  {
12839  {
12840  // use unchecked object access
12841  ptr = &ptr->operator[](reference_token);
12842  break;
12843  }
12844 
12846  {
12847  if (reference_token == "-")
12848  {
12849  // explicitly treat "-" as index beyond the end
12850  ptr = &ptr->operator[](ptr->m_value.array->size());
12851  }
12852  else
12853  {
12854  // convert array index to number; unchecked access
12855  ptr = &ptr->operator[](array_index(reference_token));
12856  }
12857  break;
12858  }
12859 
12860  case detail::value_t::null:
12868  default:
12869  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
12870  }
12871  }
12872 
12873  return *ptr;
12874  }
12875 
12883  {
12884  for (const auto& reference_token : reference_tokens)
12885  {
12886  switch (ptr->type())
12887  {
12889  {
12890  // note: at performs range check
12891  ptr = &ptr->at(reference_token);
12892  break;
12893  }
12894 
12896  {
12897  if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
12898  {
12899  // "-" always fails the range check
12901  "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12902  ") is out of range", *ptr));
12903  }
12904 
12905  // note: at performs range check
12906  ptr = &ptr->at(array_index(reference_token));
12907  break;
12908  }
12909 
12910  case detail::value_t::null:
12918  default:
12919  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
12920  }
12921  }
12922 
12923  return *ptr;
12924  }
12925 
12939  const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const
12940  {
12941  for (const auto& reference_token : reference_tokens)
12942  {
12943  switch (ptr->type())
12944  {
12946  {
12947  // use unchecked object access
12948  ptr = &ptr->operator[](reference_token);
12949  break;
12950  }
12951 
12953  {
12954  if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
12955  {
12956  // "-" cannot be used for const access
12957  JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr));
12958  }
12959 
12960  // use unchecked array access
12961  ptr = &ptr->operator[](array_index(reference_token));
12962  break;
12963  }
12964 
12965  case detail::value_t::null:
12973  default:
12974  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
12975  }
12976  }
12977 
12978  return *ptr;
12979  }
12980 
12987  const BasicJsonType& get_checked(const BasicJsonType* ptr) const
12988  {
12989  for (const auto& reference_token : reference_tokens)
12990  {
12991  switch (ptr->type())
12992  {
12994  {
12995  // note: at performs range check
12996  ptr = &ptr->at(reference_token);
12997  break;
12998  }
12999 
13001  {
13002  if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
13003  {
13004  // "-" always fails the range check
13006  "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
13007  ") is out of range", *ptr));
13008  }
13009 
13010  // note: at performs range check
13011  ptr = &ptr->at(array_index(reference_token));
13012  break;
13013  }
13014 
13015  case detail::value_t::null:
13023  default:
13024  JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
13025  }
13026  }
13027 
13028  return *ptr;
13029  }
13030 
13035  bool contains(const BasicJsonType* ptr) const
13036  {
13037  for (const auto& reference_token : reference_tokens)
13038  {
13039  switch (ptr->type())
13040  {
13042  {
13043  if (!ptr->contains(reference_token))
13044  {
13045  // we did not find the key in the object
13046  return false;
13047  }
13048 
13049  ptr = &ptr->operator[](reference_token);
13050  break;
13051  }
13052 
13054  {
13055  if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
13056  {
13057  // "-" always fails the range check
13058  return false;
13059  }
13060  if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9")))
13061  {
13062  // invalid char
13063  return false;
13064  }
13065  if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
13066  {
13067  if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9')))
13068  {
13069  // first char should be between '1' and '9'
13070  return false;
13071  }
13072  for (std::size_t i = 1; i < reference_token.size(); i++)
13073  {
13074  if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9')))
13075  {
13076  // other char should be between '0' and '9'
13077  return false;
13078  }
13079  }
13080  }
13081 
13082  const auto idx = array_index(reference_token);
13083  if (idx >= ptr->size())
13084  {
13085  // index out of range
13086  return false;
13087  }
13088 
13089  ptr = &ptr->operator[](idx);
13090  break;
13091  }
13092 
13093  case detail::value_t::null:
13101  default:
13102  {
13103  // we do not expect primitive values if there is still a
13104  // reference token to process
13105  return false;
13106  }
13107  }
13108  }
13109 
13110  // no reference token left means we found a primitive value
13111  return true;
13112  }
13113 
13123  static std::vector<std::string> split(const std::string& reference_string)
13124  {
13125  std::vector<std::string> result;
13126 
13127  // special case: empty reference string -> no reference tokens
13128  if (reference_string.empty())
13129  {
13130  return result;
13131  }
13132 
13133  // check if nonempty reference string begins with slash
13134  if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/'))
13135  {
13136  JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType()));
13137  }
13138 
13139  // extract the reference tokens:
13140  // - slash: position of the last read slash (or end of string)
13141  // - start: position after the previous slash
13142  for (
13143  // search for the first slash after the first character
13144  std::size_t slash = reference_string.find_first_of('/', 1),
13145  // set the beginning of the first reference token
13146  start = 1;
13147  // we can stop if start == 0 (if slash == std::string::npos)
13148  start != 0;
13149  // set the beginning of the next reference token
13150  // (will eventually be 0 if slash == std::string::npos)
13151  start = (slash == std::string::npos) ? 0 : slash + 1,
13152  // find next slash
13153  slash = reference_string.find_first_of('/', start))
13154  {
13155  // use the text between the beginning of the reference token
13156  // (start) and the last slash (slash).
13157  auto reference_token = reference_string.substr(start, slash - start);
13158 
13159  // check reference tokens are properly escaped
13160  for (std::size_t pos = reference_token.find_first_of('~');
13161  pos != std::string::npos;
13162  pos = reference_token.find_first_of('~', pos + 1))
13163  {
13164  JSON_ASSERT(reference_token[pos] == '~');
13165 
13166  // ~ must be followed by 0 or 1
13167  if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 ||
13168  (reference_token[pos + 1] != '0' &&
13169  reference_token[pos + 1] != '1')))
13170  {
13171  JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType()));
13172  }
13173  }
13174 
13175  // finally, store the reference token
13176  detail::unescape(reference_token);
13177  result.push_back(reference_token);
13178  }
13179 
13180  return result;
13181  }
13182 
13183  private:
13191  static void flatten(const std::string& reference_string,
13192  const BasicJsonType& value,
13194  {
13195  switch (value.type())
13196  {
13198  {
13199  if (value.m_value.array->empty())
13200  {
13201  // flatten empty array as null
13202  result[reference_string] = nullptr;
13203  }
13204  else
13205  {
13206  // iterate array and use index as reference string
13207  for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
13208  {
13209  flatten(reference_string + "/" + std::to_string(i),
13210  value.m_value.array->operator[](i), result);
13211  }
13212  }
13213  break;
13214  }
13215 
13217  {
13218  if (value.m_value.object->empty())
13219  {
13220  // flatten empty object as null
13221  result[reference_string] = nullptr;
13222  }
13223  else
13224  {
13225  // iterate object and use keys as reference string
13226  for (const auto& element : *value.m_value.object)
13227  {
13228  flatten(reference_string + "/" + detail::escape(element.first), element.second, result);
13229  }
13230  }
13231  break;
13232  }
13233 
13234  case detail::value_t::null:
13242  default:
13243  {
13244  // add primitive value with its reference string
13245  result[reference_string] = value;
13246  break;
13247  }
13248  }
13249  }
13250 
13261  static BasicJsonType
13263  {
13264  if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
13265  {
13266  JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value));
13267  }
13268 
13270 
13271  // iterate the JSON object values
13272  for (const auto& element : *value.m_value.object)
13273  {
13274  if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
13275  {
13276  JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second));
13277  }
13278 
13279  // assign value to reference pointed to by JSON pointer; Note that if
13280  // the JSON pointer is "" (i.e., points to the whole value), function
13281  // get_and_create returns a reference to result itself. An assignment
13282  // will then create a primitive value.
13283  json_pointer(element.first).get_and_create(result) = element.second;
13284  }
13285 
13286  return result;
13287  }
13288 
13300  friend bool operator==(json_pointer const& lhs,
13301  json_pointer const& rhs) noexcept
13302  {
13303  return lhs.reference_tokens == rhs.reference_tokens;
13304  }
13305 
13317  friend bool operator!=(json_pointer const& lhs,
13318  json_pointer const& rhs) noexcept
13319  {
13320  return !(lhs == rhs);
13321  }
13322 
13324  std::vector<std::string> reference_tokens;
13325 };
13326 } // namespace nlohmann
13327 
13328 // #include <nlohmann/detail/json_ref.hpp>
13329 
13330 
13331 #include <initializer_list>
13332 #include <utility>
13333 
13334 // #include <nlohmann/detail/meta/type_traits.hpp>
13335 
13336 
13337 namespace nlohmann
13338 {
13339 namespace detail
13340 {
13341 template<typename BasicJsonType>
13342 class json_ref
13343 {
13344  public:
13345  using value_type = BasicJsonType;
13346 
13348  : owned_value(std::move(value))
13349  {}
13350 
13351  json_ref(const value_type& value)
13352  : value_ref(&value)
13353  {}
13354 
13355  json_ref(std::initializer_list<json_ref> init)
13356  : owned_value(init)
13357  {}
13358 
13359  template <
13360  class... Args,
13361  enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
13362  json_ref(Args && ... args)
13363  : owned_value(std::forward<Args>(args)...)
13364  {}
13365 
13366  // class should be movable only
13367  json_ref(json_ref&&) noexcept = default;
13368  json_ref(const json_ref&) = delete;
13369  json_ref& operator=(const json_ref&) = delete;
13370  json_ref& operator=(json_ref&&) = delete;
13371  ~json_ref() = default;
13372 
13374  {
13375  if (value_ref == nullptr)
13376  {
13377  return std::move(owned_value);
13378  }
13379  return *value_ref;
13380  }
13381 
13382  value_type const& operator*() const
13383  {
13384  return value_ref ? *value_ref : owned_value;
13385  }
13386 
13387  value_type const* operator->() const
13388  {
13389  return &** this;
13390  }
13391 
13392  private:
13393  mutable value_type owned_value = nullptr;
13394  value_type const* value_ref = nullptr;
13395 };
13396 } // namespace detail
13397 } // namespace nlohmann
13398 
13399 // #include <nlohmann/detail/macro_scope.hpp>
13400 
13401 // #include <nlohmann/detail/string_escape.hpp>
13402 
13403 // #include <nlohmann/detail/meta/cpp_future.hpp>
13404 
13405 // #include <nlohmann/detail/meta/type_traits.hpp>
13406 
13407 // #include <nlohmann/detail/output/binary_writer.hpp>
13408 
13409 
13410 #include <algorithm> // reverse
13411 #include <array> // array
13412 #include <cmath> // isnan, isinf
13413 #include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
13414 #include <cstring> // memcpy
13415 #include <limits> // numeric_limits
13416 #include <string> // string
13417 #include <utility> // move
13418 
13419 // #include <nlohmann/detail/input/binary_reader.hpp>
13420 
13421 // #include <nlohmann/detail/macro_scope.hpp>
13422 
13423 // #include <nlohmann/detail/output/output_adapters.hpp>
13424 
13425 
13426 #include <algorithm> // copy
13427 #include <cstddef> // size_t
13428 #include <iterator> // back_inserter
13429 #include <memory> // shared_ptr, make_shared
13430 #include <string> // basic_string
13431 #include <vector> // vector
13432 
13433 #ifndef JSON_NO_IO
13434  #include <ios> // streamsize
13435  #include <ostream> // basic_ostream
13436 #endif // JSON_NO_IO
13437 
13438 // #include <nlohmann/detail/macro_scope.hpp>
13439 
13440 
13441 namespace nlohmann
13442 {
13443 namespace detail
13444 {
13446 template<typename CharType> struct output_adapter_protocol
13447 {
13448  virtual void write_character(CharType c) = 0;
13449  virtual void write_characters(const CharType* s, std::size_t length) = 0;
13450  virtual ~output_adapter_protocol() = default;
13451 
13452  output_adapter_protocol() = default;
13454  output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
13455  output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
13456  output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
13457 };
13458 
13460 template<typename CharType>
13461 using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
13462 
13464 template<typename CharType>
13466 {
13467  public:
13468  explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
13469  : v(vec)
13470  {}
13471 
13472  void write_character(CharType c) override
13473  {
13474  v.push_back(c);
13475  }
13476 
13478  void write_characters(const CharType* s, std::size_t length) override
13479  {
13480  std::copy(s, s + length, std::back_inserter(v));
13481  }
13482 
13483  private:
13484  std::vector<CharType>& v;
13485 };
13486 
13487 #ifndef JSON_NO_IO
13488 template<typename CharType>
13491 {
13492  public:
13493  explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
13494  : stream(s)
13495  {}
13496 
13497  void write_character(CharType c) override
13498  {
13499  stream.put(c);
13500  }
13501 
13503  void write_characters(const CharType* s, std::size_t length) override
13504  {
13505  stream.write(s, static_cast<std::streamsize>(length));
13506  }
13507 
13508  private:
13509  std::basic_ostream<CharType>& stream;
13510 };
13511 #endif // JSON_NO_IO
13512 
13514 template<typename CharType, typename StringType = std::basic_string<CharType>>
13516 {
13517  public:
13518  explicit output_string_adapter(StringType& s) noexcept
13519  : str(s)
13520  {}
13521 
13522  void write_character(CharType c) override
13523  {
13524  str.push_back(c);
13525  }
13526 
13528  void write_characters(const CharType* s, std::size_t length) override
13529  {
13530  str.append(s, length);
13531  }
13532 
13533  private:
13534  StringType& str;
13535 };
13536 
13537 template<typename CharType, typename StringType = std::basic_string<CharType>>
13539 {
13540  public:
13541  output_adapter(std::vector<CharType>& vec)
13542  : oa(std::make_shared<output_vector_adapter<CharType>>(vec)) {}
13543 
13544 #ifndef JSON_NO_IO
13545  output_adapter(std::basic_ostream<CharType>& s)
13546  : oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
13547 #endif // JSON_NO_IO
13548 
13549  output_adapter(StringType& s)
13550  : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
13551 
13553  {
13554  return oa;
13555  }
13556 
13557  private:
13559 };
13560 } // namespace detail
13561 } // namespace nlohmann
13562 
13563 
13564 namespace nlohmann
13565 {
13566 namespace detail
13567 {
13569 // binary writer //
13571 
13575 template<typename BasicJsonType, typename CharType>
13577 {
13578  using string_t = typename BasicJsonType::string_t;
13579  using binary_t = typename BasicJsonType::binary_t;
13580  using number_float_t = typename BasicJsonType::number_float_t;
13581 
13582  public:
13588  explicit binary_writer(output_adapter_t<CharType> adapter) : oa(std::move(adapter))
13589  {
13590  JSON_ASSERT(oa);
13591  }
13592 
13597  void write_bson(const BasicJsonType& j)
13598  {
13599  switch (j.type())
13600  {
13601  case value_t::object:
13602  {
13603  write_bson_object(*j.m_value.object);
13604  break;
13605  }
13606 
13607  case value_t::null:
13608  case value_t::array:
13609  case value_t::string:
13610  case value_t::boolean:
13613  case value_t::number_float:
13614  case value_t::binary:
13615  case value_t::discarded:
13616  default:
13617  {
13618  JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));;
13619  }
13620  }
13621  }
13622 
13626  void write_cbor(const BasicJsonType& j)
13627  {
13628  switch (j.type())
13629  {
13630  case value_t::null:
13631  {
13632  oa->write_character(to_char_type(0xF6));
13633  break;
13634  }
13635 
13636  case value_t::boolean:
13637  {
13638  oa->write_character(j.m_value.boolean
13639  ? to_char_type(0xF5)
13640  : to_char_type(0xF4));
13641  break;
13642  }
13643 
13645  {
13646  if (j.m_value.number_integer >= 0)
13647  {
13648  // CBOR does not differentiate between positive signed
13649  // integers and unsigned integers. Therefore, we used the
13650  // code from the value_t::number_unsigned case here.
13651  if (j.m_value.number_integer <= 0x17)
13652  {
13653  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13654  }
13655  else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13656  {
13657  oa->write_character(to_char_type(0x18));
13658  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13659  }
13660  else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13661  {
13662  oa->write_character(to_char_type(0x19));
13663  write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13664  }
13665  else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13666  {
13667  oa->write_character(to_char_type(0x1A));
13668  write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13669  }
13670  else
13671  {
13672  oa->write_character(to_char_type(0x1B));
13673  write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13674  }
13675  }
13676  else
13677  {
13678  // The conversions below encode the sign in the first
13679  // byte, and the value is converted to a positive number.
13680  const auto positive_number = -1 - j.m_value.number_integer;
13681  if (j.m_value.number_integer >= -24)
13682  {
13683  write_number(static_cast<std::uint8_t>(0x20 + positive_number));
13684  }
13685  else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13686  {
13687  oa->write_character(to_char_type(0x38));
13688  write_number(static_cast<std::uint8_t>(positive_number));
13689  }
13690  else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13691  {
13692  oa->write_character(to_char_type(0x39));
13693  write_number(static_cast<std::uint16_t>(positive_number));
13694  }
13695  else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13696  {
13697  oa->write_character(to_char_type(0x3A));
13698  write_number(static_cast<std::uint32_t>(positive_number));
13699  }
13700  else
13701  {
13702  oa->write_character(to_char_type(0x3B));
13703  write_number(static_cast<std::uint64_t>(positive_number));
13704  }
13705  }
13706  break;
13707  }
13708 
13710  {
13711  if (j.m_value.number_unsigned <= 0x17)
13712  {
13713  write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13714  }
13715  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13716  {
13717  oa->write_character(to_char_type(0x18));
13718  write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13719  }
13720  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13721  {
13722  oa->write_character(to_char_type(0x19));
13723  write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
13724  }
13725  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13726  {
13727  oa->write_character(to_char_type(0x1A));
13728  write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
13729  }
13730  else
13731  {
13732  oa->write_character(to_char_type(0x1B));
13733  write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
13734  }
13735  break;
13736  }
13737 
13738  case value_t::number_float:
13739  {
13740  if (std::isnan(j.m_value.number_float))
13741  {
13742  // NaN is 0xf97e00 in CBOR
13743  oa->write_character(to_char_type(0xF9));
13744  oa->write_character(to_char_type(0x7E));
13745  oa->write_character(to_char_type(0x00));
13746  }
13747  else if (std::isinf(j.m_value.number_float))
13748  {
13749  // Infinity is 0xf97c00, -Infinity is 0xf9fc00
13750  oa->write_character(to_char_type(0xf9));
13751  oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
13752  oa->write_character(to_char_type(0x00));
13753  }
13754  else
13755  {
13756  write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
13757  }
13758  break;
13759  }
13760 
13761  case value_t::string:
13762  {
13763  // step 1: write control byte and the string length
13764  const auto N = j.m_value.string->size();
13765  if (N <= 0x17)
13766  {
13767  write_number(static_cast<std::uint8_t>(0x60 + N));
13768  }
13769  else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13770  {
13771  oa->write_character(to_char_type(0x78));
13772  write_number(static_cast<std::uint8_t>(N));
13773  }
13774  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13775  {
13776  oa->write_character(to_char_type(0x79));
13777  write_number(static_cast<std::uint16_t>(N));
13778  }
13779  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13780  {
13781  oa->write_character(to_char_type(0x7A));
13782  write_number(static_cast<std::uint32_t>(N));
13783  }
13784  // LCOV_EXCL_START
13785  else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13786  {
13787  oa->write_character(to_char_type(0x7B));
13788  write_number(static_cast<std::uint64_t>(N));
13789  }
13790  // LCOV_EXCL_STOP
13791 
13792  // step 2: write the string
13793  oa->write_characters(
13794  reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13795  j.m_value.string->size());
13796  break;
13797  }
13798 
13799  case value_t::array:
13800  {
13801  // step 1: write control byte and the array size
13802  const auto N = j.m_value.array->size();
13803  if (N <= 0x17)
13804  {
13805  write_number(static_cast<std::uint8_t>(0x80 + N));
13806  }
13807  else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13808  {
13809  oa->write_character(to_char_type(0x98));
13810  write_number(static_cast<std::uint8_t>(N));
13811  }
13812  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13813  {
13814  oa->write_character(to_char_type(0x99));
13815  write_number(static_cast<std::uint16_t>(N));
13816  }
13817  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13818  {
13819  oa->write_character(to_char_type(0x9A));
13820  write_number(static_cast<std::uint32_t>(N));
13821  }
13822  // LCOV_EXCL_START
13823  else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13824  {
13825  oa->write_character(to_char_type(0x9B));
13826  write_number(static_cast<std::uint64_t>(N));
13827  }
13828  // LCOV_EXCL_STOP
13829 
13830  // step 2: write each element
13831  for (const auto& el : *j.m_value.array)
13832  {
13833  write_cbor(el);
13834  }
13835  break;
13836  }
13837 
13838  case value_t::binary:
13839  {
13840  if (j.m_value.binary->has_subtype())
13841  {
13842  if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
13843  {
13844  write_number(static_cast<std::uint8_t>(0xd8));
13845  write_number(static_cast<std::uint8_t>(j.m_value.binary->subtype()));
13846  }
13847  else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
13848  {
13849  write_number(static_cast<std::uint8_t>(0xd9));
13850  write_number(static_cast<std::uint16_t>(j.m_value.binary->subtype()));
13851  }
13852  else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
13853  {
13854  write_number(static_cast<std::uint8_t>(0xda));
13855  write_number(static_cast<std::uint32_t>(j.m_value.binary->subtype()));
13856  }
13857  else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
13858  {
13859  write_number(static_cast<std::uint8_t>(0xdb));
13860  write_number(static_cast<std::uint64_t>(j.m_value.binary->subtype()));
13861  }
13862  }
13863 
13864  // step 1: write control byte and the binary array size
13865  const auto N = j.m_value.binary->size();
13866  if (N <= 0x17)
13867  {
13868  write_number(static_cast<std::uint8_t>(0x40 + N));
13869  }
13870  else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13871  {
13872  oa->write_character(to_char_type(0x58));
13873  write_number(static_cast<std::uint8_t>(N));
13874  }
13875  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13876  {
13877  oa->write_character(to_char_type(0x59));
13878  write_number(static_cast<std::uint16_t>(N));
13879  }
13880  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13881  {
13882  oa->write_character(to_char_type(0x5A));
13883  write_number(static_cast<std::uint32_t>(N));
13884  }
13885  // LCOV_EXCL_START
13886  else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13887  {
13888  oa->write_character(to_char_type(0x5B));
13889  write_number(static_cast<std::uint64_t>(N));
13890  }
13891  // LCOV_EXCL_STOP
13892 
13893  // step 2: write each element
13894  oa->write_characters(
13895  reinterpret_cast<const CharType*>(j.m_value.binary->data()),
13896  N);
13897 
13898  break;
13899  }
13900 
13901  case value_t::object:
13902  {
13903  // step 1: write control byte and the object size
13904  const auto N = j.m_value.object->size();
13905  if (N <= 0x17)
13906  {
13907  write_number(static_cast<std::uint8_t>(0xA0 + N));
13908  }
13909  else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13910  {
13911  oa->write_character(to_char_type(0xB8));
13912  write_number(static_cast<std::uint8_t>(N));
13913  }
13914  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13915  {
13916  oa->write_character(to_char_type(0xB9));
13917  write_number(static_cast<std::uint16_t>(N));
13918  }
13919  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13920  {
13921  oa->write_character(to_char_type(0xBA));
13922  write_number(static_cast<std::uint32_t>(N));
13923  }
13924  // LCOV_EXCL_START
13925  else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13926  {
13927  oa->write_character(to_char_type(0xBB));
13928  write_number(static_cast<std::uint64_t>(N));
13929  }
13930  // LCOV_EXCL_STOP
13931 
13932  // step 2: write each element
13933  for (const auto& el : *j.m_value.object)
13934  {
13935  write_cbor(el.first);
13936  write_cbor(el.second);
13937  }
13938  break;
13939  }
13940 
13941  case value_t::discarded:
13942  default:
13943  break;
13944  }
13945  }
13946 
13950  void write_msgpack(const BasicJsonType& j)
13951  {
13952  switch (j.type())
13953  {
13954  case value_t::null: // nil
13955  {
13956  oa->write_character(to_char_type(0xC0));
13957  break;
13958  }
13959 
13960  case value_t::boolean: // true and false
13961  {
13962  oa->write_character(j.m_value.boolean
13963  ? to_char_type(0xC3)
13964  : to_char_type(0xC2));
13965  break;
13966  }
13967 
13969  {
13970  if (j.m_value.number_integer >= 0)
13971  {
13972  // MessagePack does not differentiate between positive
13973  // signed integers and unsigned integers. Therefore, we used
13974  // the code from the value_t::number_unsigned case here.
13975  if (j.m_value.number_unsigned < 128)
13976  {
13977  // positive fixnum
13978  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13979  }
13980  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13981  {
13982  // uint 8
13983  oa->write_character(to_char_type(0xCC));
13984  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13985  }
13986  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13987  {
13988  // uint 16
13989  oa->write_character(to_char_type(0xCD));
13990  write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13991  }
13992  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13993  {
13994  // uint 32
13995  oa->write_character(to_char_type(0xCE));
13996  write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13997  }
13998  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13999  {
14000  // uint 64
14001  oa->write_character(to_char_type(0xCF));
14002  write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
14003  }
14004  }
14005  else
14006  {
14007  if (j.m_value.number_integer >= -32)
14008  {
14009  // negative fixnum
14010  write_number(static_cast<std::int8_t>(j.m_value.number_integer));
14011  }
14012  else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14013  j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14014  {
14015  // int 8
14016  oa->write_character(to_char_type(0xD0));
14017  write_number(static_cast<std::int8_t>(j.m_value.number_integer));
14018  }
14019  else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14020  j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14021  {
14022  // int 16
14023  oa->write_character(to_char_type(0xD1));
14024  write_number(static_cast<std::int16_t>(j.m_value.number_integer));
14025  }
14026  else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14027  j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14028  {
14029  // int 32
14030  oa->write_character(to_char_type(0xD2));
14031  write_number(static_cast<std::int32_t>(j.m_value.number_integer));
14032  }
14033  else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14034  j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14035  {
14036  // int 64
14037  oa->write_character(to_char_type(0xD3));
14038  write_number(static_cast<std::int64_t>(j.m_value.number_integer));
14039  }
14040  }
14041  break;
14042  }
14043 
14045  {
14046  if (j.m_value.number_unsigned < 128)
14047  {
14048  // positive fixnum
14049  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
14050  }
14051  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14052  {
14053  // uint 8
14054  oa->write_character(to_char_type(0xCC));
14055  write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
14056  }
14057  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14058  {
14059  // uint 16
14060  oa->write_character(to_char_type(0xCD));
14061  write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
14062  }
14063  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14064  {
14065  // uint 32
14066  oa->write_character(to_char_type(0xCE));
14067  write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
14068  }
14069  else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14070  {
14071  // uint 64
14072  oa->write_character(to_char_type(0xCF));
14073  write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
14074  }
14075  break;
14076  }
14077 
14078  case value_t::number_float:
14079  {
14080  write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
14081  break;
14082  }
14083 
14084  case value_t::string:
14085  {
14086  // step 1: write control byte and the string length
14087  const auto N = j.m_value.string->size();
14088  if (N <= 31)
14089  {
14090  // fixstr
14091  write_number(static_cast<std::uint8_t>(0xA0 | N));
14092  }
14093  else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14094  {
14095  // str 8
14096  oa->write_character(to_char_type(0xD9));
14097  write_number(static_cast<std::uint8_t>(N));
14098  }
14099  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14100  {
14101  // str 16
14102  oa->write_character(to_char_type(0xDA));
14103  write_number(static_cast<std::uint16_t>(N));
14104  }
14105  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14106  {
14107  // str 32
14108  oa->write_character(to_char_type(0xDB));
14109  write_number(static_cast<std::uint32_t>(N));
14110  }
14111 
14112  // step 2: write the string
14113  oa->write_characters(
14114  reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
14115  j.m_value.string->size());
14116  break;
14117  }
14118 
14119  case value_t::array:
14120  {
14121  // step 1: write control byte and the array size
14122  const auto N = j.m_value.array->size();
14123  if (N <= 15)
14124  {
14125  // fixarray
14126  write_number(static_cast<std::uint8_t>(0x90 | N));
14127  }
14128  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14129  {
14130  // array 16
14131  oa->write_character(to_char_type(0xDC));
14132  write_number(static_cast<std::uint16_t>(N));
14133  }
14134  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14135  {
14136  // array 32
14137  oa->write_character(to_char_type(0xDD));
14138  write_number(static_cast<std::uint32_t>(N));
14139  }
14140 
14141  // step 2: write each element
14142  for (const auto& el : *j.m_value.array)
14143  {
14144  write_msgpack(el);
14145  }
14146  break;
14147  }
14148 
14149  case value_t::binary:
14150  {
14151  // step 0: determine if the binary type has a set subtype to
14152  // determine whether or not to use the ext or fixext types
14153  const bool use_ext = j.m_value.binary->has_subtype();
14154 
14155  // step 1: write control byte and the byte string length
14156  const auto N = j.m_value.binary->size();
14158  {
14159  std::uint8_t output_type{};
14160  bool fixed = true;
14161  if (use_ext)
14162  {
14163  switch (N)
14164  {
14165  case 1:
14166  output_type = 0xD4; // fixext 1
14167  break;
14168  case 2:
14169  output_type = 0xD5; // fixext 2
14170  break;
14171  case 4:
14172  output_type = 0xD6; // fixext 4
14173  break;
14174  case 8:
14175  output_type = 0xD7; // fixext 8
14176  break;
14177  case 16:
14178  output_type = 0xD8; // fixext 16
14179  break;
14180  default:
14181  output_type = 0xC7; // ext 8
14182  fixed = false;
14183  break;
14184  }
14185 
14186  }
14187  else
14188  {
14189  output_type = 0xC4; // bin 8
14190  fixed = false;
14191  }
14192 
14193  oa->write_character(to_char_type(output_type));
14194  if (!fixed)
14195  {
14196  write_number(static_cast<std::uint8_t>(N));
14197  }
14198  }
14199  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14200  {
14201  std::uint8_t output_type = use_ext
14202  ? 0xC8 // ext 16
14203  : 0xC5; // bin 16
14204 
14205  oa->write_character(to_char_type(output_type));
14206  write_number(static_cast<std::uint16_t>(N));
14207  }
14208  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14209  {
14210  std::uint8_t output_type = use_ext
14211  ? 0xC9 // ext 32
14212  : 0xC6; // bin 32
14213 
14214  oa->write_character(to_char_type(output_type));
14215  write_number(static_cast<std::uint32_t>(N));
14216  }
14217 
14218  // step 1.5: if this is an ext type, write the subtype
14219  if (use_ext)
14220  {
14221  write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
14222  }
14223 
14224  // step 2: write the byte string
14225  oa->write_characters(
14226  reinterpret_cast<const CharType*>(j.m_value.binary->data()),
14227  N);
14228 
14229  break;
14230  }
14231 
14232  case value_t::object:
14233  {
14234  // step 1: write control byte and the object size
14235  const auto N = j.m_value.object->size();
14236  if (N <= 15)
14237  {
14238  // fixmap
14239  write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
14240  }
14241  else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14242  {
14243  // map 16
14244  oa->write_character(to_char_type(0xDE));
14245  write_number(static_cast<std::uint16_t>(N));
14246  }
14247  else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14248  {
14249  // map 32
14250  oa->write_character(to_char_type(0xDF));
14251  write_number(static_cast<std::uint32_t>(N));
14252  }
14253 
14254  // step 2: write each element
14255  for (const auto& el : *j.m_value.object)
14256  {
14257  write_msgpack(el.first);
14258  write_msgpack(el.second);
14259  }
14260  break;
14261  }
14262 
14263  case value_t::discarded:
14264  default:
14265  break;
14266  }
14267  }
14268 
14275  void write_ubjson(const BasicJsonType& j, const bool use_count,
14276  const bool use_type, const bool add_prefix = true)
14277  {
14278  switch (j.type())
14279  {
14280  case value_t::null:
14281  {
14282  if (add_prefix)
14283  {
14284  oa->write_character(to_char_type('Z'));
14285  }
14286  break;
14287  }
14288 
14289  case value_t::boolean:
14290  {
14291  if (add_prefix)
14292  {
14293  oa->write_character(j.m_value.boolean
14294  ? to_char_type('T')
14295  : to_char_type('F'));
14296  }
14297  break;
14298  }
14299 
14301  {
14302  write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
14303  break;
14304  }
14305 
14307  {
14308  write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
14309  break;
14310  }
14311 
14312  case value_t::number_float:
14313  {
14314  write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
14315  break;
14316  }
14317 
14318  case value_t::string:
14319  {
14320  if (add_prefix)
14321  {
14322  oa->write_character(to_char_type('S'));
14323  }
14324  write_number_with_ubjson_prefix(j.m_value.string->size(), true);
14325  oa->write_characters(
14326  reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
14327  j.m_value.string->size());
14328  break;
14329  }
14330 
14331  case value_t::array:
14332  {
14333  if (add_prefix)
14334  {
14335  oa->write_character(to_char_type('['));
14336  }
14337 
14338  bool prefix_required = true;
14339  if (use_type && !j.m_value.array->empty())
14340  {
14341  JSON_ASSERT(use_count);
14342  const CharType first_prefix = ubjson_prefix(j.front());
14343  const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14344  [this, first_prefix](const BasicJsonType & v)
14345  {
14346  return ubjson_prefix(v) == first_prefix;
14347  });
14348 
14349  if (same_prefix)
14350  {
14351  prefix_required = false;
14352  oa->write_character(to_char_type('$'));
14353  oa->write_character(first_prefix);
14354  }
14355  }
14356 
14357  if (use_count)
14358  {
14359  oa->write_character(to_char_type('#'));
14360  write_number_with_ubjson_prefix(j.m_value.array->size(), true);
14361  }
14362 
14363  for (const auto& el : *j.m_value.array)
14364  {
14365  write_ubjson(el, use_count, use_type, prefix_required);
14366  }
14367 
14368  if (!use_count)
14369  {
14370  oa->write_character(to_char_type(']'));
14371  }
14372 
14373  break;
14374  }
14375 
14376  case value_t::binary:
14377  {
14378  if (add_prefix)
14379  {
14380  oa->write_character(to_char_type('['));
14381  }
14382 
14383  if (use_type && !j.m_value.binary->empty())
14384  {
14385  JSON_ASSERT(use_count);
14386  oa->write_character(to_char_type('$'));
14387  oa->write_character('U');
14388  }
14389 
14390  if (use_count)
14391  {
14392  oa->write_character(to_char_type('#'));
14393  write_number_with_ubjson_prefix(j.m_value.binary->size(), true);
14394  }
14395 
14396  if (use_type)
14397  {
14398  oa->write_characters(
14399  reinterpret_cast<const CharType*>(j.m_value.binary->data()),
14400  j.m_value.binary->size());
14401  }
14402  else
14403  {
14404  for (size_t i = 0; i < j.m_value.binary->size(); ++i)
14405  {
14406  oa->write_character(to_char_type('U'));
14407  oa->write_character(j.m_value.binary->data()[i]);
14408  }
14409  }
14410 
14411  if (!use_count)
14412  {
14413  oa->write_character(to_char_type(']'));
14414  }
14415 
14416  break;
14417  }
14418 
14419  case value_t::object:
14420  {
14421  if (add_prefix)
14422  {
14423  oa->write_character(to_char_type('{'));
14424  }
14425 
14426  bool prefix_required = true;
14427  if (use_type && !j.m_value.object->empty())
14428  {
14429  JSON_ASSERT(use_count);
14430  const CharType first_prefix = ubjson_prefix(j.front());
14431  const bool same_prefix = std::all_of(j.begin(), j.end(),
14432  [this, first_prefix](const BasicJsonType & v)
14433  {
14434  return ubjson_prefix(v) == first_prefix;
14435  });
14436 
14437  if (same_prefix)
14438  {
14439  prefix_required = false;
14440  oa->write_character(to_char_type('$'));
14441  oa->write_character(first_prefix);
14442  }
14443  }
14444 
14445  if (use_count)
14446  {
14447  oa->write_character(to_char_type('#'));
14448  write_number_with_ubjson_prefix(j.m_value.object->size(), true);
14449  }
14450 
14451  for (const auto& el : *j.m_value.object)
14452  {
14453  write_number_with_ubjson_prefix(el.first.size(), true);
14454  oa->write_characters(
14455  reinterpret_cast<const CharType*>(el.first.c_str()),
14456  el.first.size());
14457  write_ubjson(el.second, use_count, use_type, prefix_required);
14458  }
14459 
14460  if (!use_count)
14461  {
14462  oa->write_character(to_char_type('}'));
14463  }
14464 
14465  break;
14466  }
14467 
14468  case value_t::discarded:
14469  default:
14470  break;
14471  }
14472  }
14473 
14474  private:
14476  // BSON //
14478 
14483  static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j)
14484  {
14485  const auto it = name.find(static_cast<typename string_t::value_type>(0));
14486  if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
14487  {
14488  JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", j));
14489  static_cast<void>(j);
14490  }
14491 
14492  return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
14493  }
14494 
14499  const std::uint8_t element_type)
14500  {
14501  oa->write_character(to_char_type(element_type)); // boolean
14502  oa->write_characters(
14503  reinterpret_cast<const CharType*>(name.c_str()),
14504  name.size() + 1u);
14505  }
14506 
14511  const bool value)
14512  {
14514  oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
14515  }
14516 
14521  const double value)
14522  {
14524  write_number<double, true>(value);
14525  }
14526 
14530  static std::size_t calc_bson_string_size(const string_t& value)
14531  {
14532  return sizeof(std::int32_t) + value.size() + 1ul;
14533  }
14534 
14539  const string_t& value)
14540  {
14542 
14543  write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size() + 1ul));
14544  oa->write_characters(
14545  reinterpret_cast<const CharType*>(value.c_str()),
14546  value.size() + 1);
14547  }
14548 
14553  {
14555  }
14556 
14560  static std::size_t calc_bson_integer_size(const std::int64_t value)
14561  {
14562  return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
14563  ? sizeof(std::int32_t)
14564  : sizeof(std::int64_t);
14565  }
14566 
14571  const std::int64_t value)
14572  {
14573  if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
14574  {
14575  write_bson_entry_header(name, 0x10); // int32
14576  write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
14577  }
14578  else
14579  {
14580  write_bson_entry_header(name, 0x12); // int64
14581  write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
14582  }
14583  }
14584 
14588  static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
14589  {
14590  return (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14591  ? sizeof(std::int32_t)
14592  : sizeof(std::int64_t);
14593  }
14594 
14599  const BasicJsonType& j)
14600  {
14601  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14602  {
14603  write_bson_entry_header(name, 0x10 /* int32 */);
14604  write_number<std::int32_t, true>(static_cast<std::int32_t>(j.m_value.number_unsigned));
14605  }
14606  else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14607  {
14608  write_bson_entry_header(name, 0x12 /* int64 */);
14609  write_number<std::int64_t, true>(static_cast<std::int64_t>(j.m_value.number_unsigned));
14610  }
14611  else
14612  {
14613  JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", j));
14614  }
14615  }
14616 
14621  const typename BasicJsonType::object_t& value)
14622  {
14623  write_bson_entry_header(name, 0x03); // object
14624  write_bson_object(value);
14625  }
14626 
14630  static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
14631  {
14632  std::size_t array_index = 0ul;
14633 
14634  const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
14635  {
14636  return result + calc_bson_element_size(std::to_string(array_index++), el);
14637  });
14638 
14639  return sizeof(std::int32_t) + embedded_document_size + 1ul;
14640  }
14641 
14645  static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value)
14646  {
14647  return sizeof(std::int32_t) + value.size() + 1ul;
14648  }
14649 
14654  const typename BasicJsonType::array_t& value)
14655  {
14656  write_bson_entry_header(name, 0x04); // array
14657  write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_array_size(value)));
14658 
14659  std::size_t array_index = 0ul;
14660 
14661  for (const auto& el : value)
14662  {
14663  write_bson_element(std::to_string(array_index++), el);
14664  }
14665 
14666  oa->write_character(to_char_type(0x00));
14667  }
14668 
14673  const binary_t& value)
14674  {
14676 
14677  write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size()));
14678  write_number(value.has_subtype() ? static_cast<std::uint8_t>(value.subtype()) : std::uint8_t(0x00));
14679 
14680  oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
14681  }
14682 
14687  static std::size_t calc_bson_element_size(const string_t& name,
14688  const BasicJsonType& j)
14689  {
14690  const auto header_size = calc_bson_entry_header_size(name, j);
14691  switch (j.type())
14692  {
14693  case value_t::object:
14694  return header_size + calc_bson_object_size(*j.m_value.object);
14695 
14696  case value_t::array:
14697  return header_size + calc_bson_array_size(*j.m_value.array);
14698 
14699  case value_t::binary:
14700  return header_size + calc_bson_binary_size(*j.m_value.binary);
14701 
14702  case value_t::boolean:
14703  return header_size + 1ul;
14704 
14705  case value_t::number_float:
14706  return header_size + 8ul;
14707 
14709  return header_size + calc_bson_integer_size(j.m_value.number_integer);
14710 
14712  return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
14713 
14714  case value_t::string:
14715  return header_size + calc_bson_string_size(*j.m_value.string);
14716 
14717  case value_t::null:
14718  return header_size + 0ul;
14719 
14720  // LCOV_EXCL_START
14721  case value_t::discarded:
14722  default:
14723  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
14724  return 0ul;
14725  // LCOV_EXCL_STOP
14726  }
14727  }
14728 
14736  const BasicJsonType& j)
14737  {
14738  switch (j.type())
14739  {
14740  case value_t::object:
14741  return write_bson_object_entry(name, *j.m_value.object);
14742 
14743  case value_t::array:
14744  return write_bson_array(name, *j.m_value.array);
14745 
14746  case value_t::binary:
14747  return write_bson_binary(name, *j.m_value.binary);
14748 
14749  case value_t::boolean:
14750  return write_bson_boolean(name, j.m_value.boolean);
14751 
14752  case value_t::number_float:
14753  return write_bson_double(name, j.m_value.number_float);
14754 
14756  return write_bson_integer(name, j.m_value.number_integer);
14757 
14759  return write_bson_unsigned(name, j);
14760 
14761  case value_t::string:
14762  return write_bson_string(name, *j.m_value.string);
14763 
14764  case value_t::null:
14765  return write_bson_null(name);
14766 
14767  // LCOV_EXCL_START
14768  case value_t::discarded:
14769  default:
14770  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
14771  return;
14772  // LCOV_EXCL_STOP
14773  }
14774  }
14775 
14782  static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
14783  {
14784  std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0),
14785  [](size_t result, const typename BasicJsonType::object_t::value_type & el)
14786  {
14787  return result += calc_bson_element_size(el.first, el.second);
14788  });
14789 
14790  return sizeof(std::int32_t) + document_size + 1ul;
14791  }
14792 
14797  void write_bson_object(const typename BasicJsonType::object_t& value)
14798  {
14799  write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_object_size(value)));
14800 
14801  for (const auto& el : value)
14802  {
14803  write_bson_element(el.first, el.second);
14804  }
14805 
14806  oa->write_character(to_char_type(0x00));
14807  }
14808 
14810  // CBOR //
14812 
14813  static constexpr CharType get_cbor_float_prefix(float /*unused*/)
14814  {
14815  return to_char_type(0xFA); // Single-Precision Float
14816  }
14817 
14818  static constexpr CharType get_cbor_float_prefix(double /*unused*/)
14819  {
14820  return to_char_type(0xFB); // Double-Precision Float
14821  }
14822 
14824  // MsgPack //
14826 
14827  static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
14828  {
14829  return to_char_type(0xCA); // float 32
14830  }
14831 
14832  static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
14833  {
14834  return to_char_type(0xCB); // float 64
14835  }
14836 
14838  // UBJSON //
14840 
14841  // UBJSON: write number (floating point)
14842  template<typename NumberType, typename std::enable_if<
14844  void write_number_with_ubjson_prefix(const NumberType n,
14845  const bool add_prefix)
14846  {
14847  if (add_prefix)
14848  {
14849  oa->write_character(get_ubjson_float_prefix(n));
14850  }
14851  write_number(n);
14852  }
14853 
14854  // UBJSON: write number (unsigned integer)
14855  template<typename NumberType, typename std::enable_if<
14857  void write_number_with_ubjson_prefix(const NumberType n,
14858  const bool add_prefix)
14859  {
14860  if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
14861  {
14862  if (add_prefix)
14863  {
14864  oa->write_character(to_char_type('i')); // int8
14865  }
14866  write_number(static_cast<std::uint8_t>(n));
14867  }
14868  else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14869  {
14870  if (add_prefix)
14871  {
14872  oa->write_character(to_char_type('U')); // uint8
14873  }
14874  write_number(static_cast<std::uint8_t>(n));
14875  }
14876  else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
14877  {
14878  if (add_prefix)
14879  {
14880  oa->write_character(to_char_type('I')); // int16
14881  }
14882  write_number(static_cast<std::int16_t>(n));
14883  }
14884  else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14885  {
14886  if (add_prefix)
14887  {
14888  oa->write_character(to_char_type('l')); // int32
14889  }
14890  write_number(static_cast<std::int32_t>(n));
14891  }
14892  else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14893  {
14894  if (add_prefix)
14895  {
14896  oa->write_character(to_char_type('L')); // int64
14897  }
14898  write_number(static_cast<std::int64_t>(n));
14899  }
14900  else
14901  {
14902  if (add_prefix)
14903  {
14904  oa->write_character(to_char_type('H')); // high-precision number
14905  }
14906 
14907  const auto number = BasicJsonType(n).dump();
14908  write_number_with_ubjson_prefix(number.size(), true);
14909  for (std::size_t i = 0; i < number.size(); ++i)
14910  {
14911  oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14912  }
14913  }
14914  }
14915 
14916  // UBJSON: write number (signed integer)
14917  template < typename NumberType, typename std::enable_if <
14920  void write_number_with_ubjson_prefix(const NumberType n,
14921  const bool add_prefix)
14922  {
14923  if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14924  {
14925  if (add_prefix)
14926  {
14927  oa->write_character(to_char_type('i')); // int8
14928  }
14929  write_number(static_cast<std::int8_t>(n));
14930  }
14931  else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
14932  {
14933  if (add_prefix)
14934  {
14935  oa->write_character(to_char_type('U')); // uint8
14936  }
14937  write_number(static_cast<std::uint8_t>(n));
14938  }
14939  else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14940  {
14941  if (add_prefix)
14942  {
14943  oa->write_character(to_char_type('I')); // int16
14944  }
14945  write_number(static_cast<std::int16_t>(n));
14946  }
14947  else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14948  {
14949  if (add_prefix)
14950  {
14951  oa->write_character(to_char_type('l')); // int32
14952  }
14953  write_number(static_cast<std::int32_t>(n));
14954  }
14955  else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14956  {
14957  if (add_prefix)
14958  {
14959  oa->write_character(to_char_type('L')); // int64
14960  }
14961  write_number(static_cast<std::int64_t>(n));
14962  }
14963  // LCOV_EXCL_START
14964  else
14965  {
14966  if (add_prefix)
14967  {
14968  oa->write_character(to_char_type('H')); // high-precision number
14969  }
14970 
14971  const auto number = BasicJsonType(n).dump();
14972  write_number_with_ubjson_prefix(number.size(), true);
14973  for (std::size_t i = 0; i < number.size(); ++i)
14974  {
14975  oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14976  }
14977  }
14978  // LCOV_EXCL_STOP
14979  }
14980 
14984  CharType ubjson_prefix(const BasicJsonType& j) const noexcept
14985  {
14986  switch (j.type())
14987  {
14988  case value_t::null:
14989  return 'Z';
14990 
14991  case value_t::boolean:
14992  return j.m_value.boolean ? 'T' : 'F';
14993 
14995  {
14996  if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14997  {
14998  return 'i';
14999  }
15000  if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15001  {
15002  return 'U';
15003  }
15004  if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15005  {
15006  return 'I';
15007  }
15008  if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15009  {
15010  return 'l';
15011  }
15012  if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15013  {
15014  return 'L';
15015  }
15016  // anything else is treated as high-precision number
15017  return 'H'; // LCOV_EXCL_LINE
15018  }
15019 
15021  {
15022  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
15023  {
15024  return 'i';
15025  }
15026  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
15027  {
15028  return 'U';
15029  }
15030  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
15031  {
15032  return 'I';
15033  }
15034  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
15035  {
15036  return 'l';
15037  }
15038  if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
15039  {
15040  return 'L';
15041  }
15042  // anything else is treated as high-precision number
15043  return 'H'; // LCOV_EXCL_LINE
15044  }
15045 
15046  case value_t::number_float:
15047  return get_ubjson_float_prefix(j.m_value.number_float);
15048 
15049  case value_t::string:
15050  return 'S';
15051 
15052  case value_t::array: // fallthrough
15053  case value_t::binary:
15054  return '[';
15055 
15056  case value_t::object:
15057  return '{';
15058 
15059  case value_t::discarded:
15060  default: // discarded values
15061  return 'N';
15062  }
15063  }
15064 
15065  static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
15066  {
15067  return 'd'; // float 32
15068  }
15069 
15070  static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
15071  {
15072  return 'D'; // float 64
15073  }
15074 
15076  // Utility functions //
15078 
15079  /*
15080  @brief write a number to output input
15081  @param[in] n number of type @a NumberType
15082  @tparam NumberType the type of the number
15083  @tparam OutputIsLittleEndian Set to true if output data is
15084  required to be little endian
15085 
15086  @note This function needs to respect the system's endianess, because bytes
15087  in CBOR, MessagePack, and UBJSON are stored in network order (big
15088  endian) and therefore need reordering on little endian systems.
15089  */
15090  template<typename NumberType, bool OutputIsLittleEndian = false>
15091  void write_number(const NumberType n)
15092  {
15093  // step 1: write number to array of length NumberType
15094  std::array<CharType, sizeof(NumberType)> vec{};
15095  std::memcpy(vec.data(), &n, sizeof(NumberType));
15096 
15097  // step 2: write array to output (with possible reordering)
15098  if (is_little_endian != OutputIsLittleEndian)
15099  {
15100  // reverse byte order prior to conversion if necessary
15101  std::reverse(vec.begin(), vec.end());
15102  }
15103 
15104  oa->write_characters(vec.data(), sizeof(NumberType));
15105  }
15106 
15108  {
15109 #ifdef __GNUC__
15110 #pragma GCC diagnostic push
15111 #pragma GCC diagnostic ignored "-Wfloat-equal"
15112 #endif
15113  if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
15114  static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
15115  static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
15116  {
15117  oa->write_character(format == detail::input_format_t::cbor
15118  ? get_cbor_float_prefix(static_cast<float>(n))
15119  : get_msgpack_float_prefix(static_cast<float>(n)));
15120  write_number(static_cast<float>(n));
15121  }
15122  else
15123  {
15124  oa->write_character(format == detail::input_format_t::cbor
15127  write_number(n);
15128  }
15129 #ifdef __GNUC__
15130 #pragma GCC diagnostic pop
15131 #endif
15132  }
15133 
15134  public:
15135  // The following to_char_type functions are implement the conversion
15136  // between uint8_t and CharType. In case CharType is not unsigned,
15137  // such a conversion is required to allow values greater than 128.
15138  // See <https://github.com/nlohmann/json/issues/1286> for a discussion.
15139  template < typename C = CharType,
15141  static constexpr CharType to_char_type(std::uint8_t x) noexcept
15142  {
15143  return *reinterpret_cast<char*>(&x);
15144  }
15145 
15146  template < typename C = CharType,
15148  static CharType to_char_type(std::uint8_t x) noexcept
15149  {
15150  static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
15151  static_assert(std::is_trivial<CharType>::value, "CharType must be trivial");
15152  CharType result;
15153  std::memcpy(&result, &x, sizeof(x));
15154  return result;
15155  }
15156 
15157  template<typename C = CharType,
15159  static constexpr CharType to_char_type(std::uint8_t x) noexcept
15160  {
15161  return x;
15162  }
15163 
15164  template < typename InputCharType, typename C = CharType,
15165  enable_if_t <
15169  > * = nullptr >
15170  static constexpr CharType to_char_type(InputCharType x) noexcept
15171  {
15172  return x;
15173  }
15174 
15175  private:
15178 
15181 };
15182 } // namespace detail
15183 } // namespace nlohmann
15184 
15185 // #include <nlohmann/detail/output/output_adapters.hpp>
15186 
15187 // #include <nlohmann/detail/output/serializer.hpp>
15188 
15189 
15190 #include <algorithm> // reverse, remove, fill, find, none_of
15191 #include <array> // array
15192 #include <clocale> // localeconv, lconv
15193 #include <cmath> // labs, isfinite, isnan, signbit
15194 #include <cstddef> // size_t, ptrdiff_t
15195 #include <cstdint> // uint8_t
15196 #include <cstdio> // snprintf
15197 #include <limits> // numeric_limits
15198 #include <string> // string, char_traits
15199 #include <type_traits> // is_same
15200 #include <utility> // move
15201 
15202 // #include <nlohmann/detail/conversions/to_chars.hpp>
15203 
15204 
15205 #include <array> // array
15206 #include <cmath> // signbit, isfinite
15207 #include <cstdint> // intN_t, uintN_t
15208 #include <cstring> // memcpy, memmove
15209 #include <limits> // numeric_limits
15210 #include <type_traits> // conditional
15211 
15212 // #include <nlohmann/detail/macro_scope.hpp>
15213 
15214 
15215 namespace nlohmann
15216 {
15217 namespace detail
15218 {
15219 
15239 namespace dtoa_impl
15240 {
15241 
15242 template<typename Target, typename Source>
15243 Target reinterpret_bits(const Source source)
15244 {
15245  static_assert(sizeof(Target) == sizeof(Source), "size mismatch");
15246 
15247  Target target;
15248  std::memcpy(&target, &source, sizeof(Source));
15249  return target;
15250 }
15251 
15252 struct diyfp // f * 2^e
15253 {
15254  static constexpr int kPrecision = 64; // = q
15255 
15256  std::uint64_t f = 0;
15257  int e = 0;
15258 
15259  constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
15260 
15265  static diyfp sub(const diyfp& x, const diyfp& y) noexcept
15266  {
15267  JSON_ASSERT(x.e == y.e);
15268  JSON_ASSERT(x.f >= y.f);
15269 
15270  return {x.f - y.f, x.e};
15271  }
15272 
15277  static diyfp mul(const diyfp& x, const diyfp& y) noexcept
15278  {
15279  static_assert(kPrecision == 64, "internal error");
15280 
15281  // Computes:
15282  // f = round((x.f * y.f) / 2^q)
15283  // e = x.e + y.e + q
15284 
15285  // Emulate the 64-bit * 64-bit multiplication:
15286  //
15287  // p = u * v
15288  // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi)
15289  // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi )
15290  // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 )
15291  // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 )
15292  // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3)
15293  // = (p0_lo ) + 2^32 (Q ) + 2^64 (H )
15294  // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H )
15295  //
15296  // (Since Q might be larger than 2^32 - 1)
15297  //
15298  // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H)
15299  //
15300  // (Q_hi + H does not overflow a 64-bit int)
15301  //
15302  // = p_lo + 2^64 p_hi
15303 
15304  const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
15305  const std::uint64_t u_hi = x.f >> 32u;
15306  const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
15307  const std::uint64_t v_hi = y.f >> 32u;
15308 
15309  const std::uint64_t p0 = u_lo * v_lo;
15310  const std::uint64_t p1 = u_lo * v_hi;
15311  const std::uint64_t p2 = u_hi * v_lo;
15312  const std::uint64_t p3 = u_hi * v_hi;
15313 
15314  const std::uint64_t p0_hi = p0 >> 32u;
15315  const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15316  const std::uint64_t p1_hi = p1 >> 32u;
15317  const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15318  const std::uint64_t p2_hi = p2 >> 32u;
15319 
15320  std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15321 
15322  // The full product might now be computed as
15323  //
15324  // p_hi = p3 + p2_hi + p1_hi + (Q >> 32)
15325  // p_lo = p0_lo + (Q << 32)
15326  //
15327  // But in this particular case here, the full p_lo is not required.
15328  // Effectively we only need to add the highest bit in p_lo to p_hi (and
15329  // Q_hi + 1 does not overflow).
15330 
15331  Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
15332 
15333  const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15334 
15335  return {h, x.e + y.e + 64};
15336  }
15337 
15342  static diyfp normalize(diyfp x) noexcept
15343  {
15344  JSON_ASSERT(x.f != 0);
15345 
15346  while ((x.f >> 63u) == 0)
15347  {
15348  x.f <<= 1u;
15349  x.e--;
15350  }
15351 
15352  return x;
15353  }
15354 
15359  static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept
15360  {
15361  const int delta = x.e - target_exponent;
15362 
15363  JSON_ASSERT(delta >= 0);
15364  JSON_ASSERT(((x.f << delta) >> delta) == x.f);
15365 
15366  return {x.f << delta, target_exponent};
15367  }
15368 };
15369 
15371 {
15375 };
15376 
15383 template<typename FloatType>
15385 {
15386  JSON_ASSERT(std::isfinite(value));
15387  JSON_ASSERT(value > 0);
15388 
15389  // Convert the IEEE representation into a diyfp.
15390  //
15391  // If v is denormal:
15392  // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1))
15393  // If v is normalized:
15394  // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
15395 
15396  static_assert(std::numeric_limits<FloatType>::is_iec559,
15397  "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15398 
15399  constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
15400  constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15401  constexpr int kMinExp = 1 - kBias;
15402  constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
15403 
15405 
15406  const auto bits = static_cast<std::uint64_t>(reinterpret_bits<bits_type>(value));
15407  const std::uint64_t E = bits >> (kPrecision - 1);
15408  const std::uint64_t F = bits & (kHiddenBit - 1);
15409 
15410  const bool is_denormal = E == 0;
15411  const diyfp v = is_denormal
15412  ? diyfp(F, kMinExp)
15413  : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
15414 
15415  // Compute the boundaries m- and m+ of the floating-point value
15416  // v = f * 2^e.
15417  //
15418  // Determine v- and v+, the floating-point predecessor and successor if v,
15419  // respectively.
15420  //
15421  // v- = v - 2^e if f != 2^(p-1) or e == e_min (A)
15422  // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B)
15423  //
15424  // v+ = v + 2^e
15425  //
15426  // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_
15427  // between m- and m+ round to v, regardless of how the input rounding
15428  // algorithm breaks ties.
15429  //
15430  // ---+-------------+-------------+-------------+-------------+--- (A)
15431  // v- m- v m+ v+
15432  //
15433  // -----------------+------+------+-------------+-------------+--- (B)
15434  // v- m- v m+ v+
15435 
15436  const bool lower_boundary_is_closer = F == 0 && E > 1;
15437  const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
15438  const diyfp m_minus = lower_boundary_is_closer
15439  ? diyfp(4 * v.f - 1, v.e - 2) // (B)
15440  : diyfp(2 * v.f - 1, v.e - 1); // (A)
15441 
15442  // Determine the normalized w+ = m+.
15443  const diyfp w_plus = diyfp::normalize(m_plus);
15444 
15445  // Determine w- = m- such that e_(w-) = e_(w+).
15446  const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
15447 
15448  return {diyfp::normalize(v), w_minus, w_plus};
15449 }
15450 
15451 // Given normalized diyfp w, Grisu needs to find a (normalized) cached
15452 // power-of-ten c, such that the exponent of the product c * w = f * 2^e lies
15453 // within a certain range [alpha, gamma] (Definition 3.2 from [1])
15454 //
15455 // alpha <= e = e_c + e_w + q <= gamma
15456 //
15457 // or
15458 //
15459 // f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q
15460 // <= f_c * f_w * 2^gamma
15461 //
15462 // Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies
15463 //
15464 // 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma
15465 //
15466 // or
15467 //
15468 // 2^(q - 2 + alpha) <= c * w < 2^(q + gamma)
15469 //
15470 // The choice of (alpha,gamma) determines the size of the table and the form of
15471 // the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well
15472 // in practice:
15473 //
15474 // The idea is to cut the number c * w = f * 2^e into two parts, which can be
15475 // processed independently: An integral part p1, and a fractional part p2:
15476 //
15477 // f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e
15478 // = (f div 2^-e) + (f mod 2^-e) * 2^e
15479 // = p1 + p2 * 2^e
15480 //
15481 // The conversion of p1 into decimal form requires a series of divisions and
15482 // modulos by (a power of) 10. These operations are faster for 32-bit than for
15483 // 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be
15484 // achieved by choosing
15485 //
15486 // -e >= 32 or e <= -32 := gamma
15487 //
15488 // In order to convert the fractional part
15489 //
15490 // p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ...
15491 //
15492 // into decimal form, the fraction is repeatedly multiplied by 10 and the digits
15493 // d[-i] are extracted in order:
15494 //
15495 // (10 * p2) div 2^-e = d[-1]
15496 // (10 * p2) mod 2^-e = d[-2] / 10^1 + ...
15497 //
15498 // The multiplication by 10 must not overflow. It is sufficient to choose
15499 //
15500 // 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64.
15501 //
15502 // Since p2 = f mod 2^-e < 2^-e,
15503 //
15504 // -e <= 60 or e >= -60 := alpha
15505 
15506 constexpr int kAlpha = -60;
15507 constexpr int kGamma = -32;
15508 
15509 struct cached_power // c = f * 2^e ~= 10^k
15510 {
15511  std::uint64_t f;
15512  int e;
15513  int k;
15514 };
15515 
15524 {
15525  // Now
15526  //
15527  // alpha <= e_c + e + q <= gamma (1)
15528  // ==> f_c * 2^alpha <= c * 2^e * 2^q
15529  //
15530  // and since the c's are normalized, 2^(q-1) <= f_c,
15531  //
15532  // ==> 2^(q - 1 + alpha) <= c * 2^(e + q)
15533  // ==> 2^(alpha - e - 1) <= c
15534  //
15535  // If c were an exact power of ten, i.e. c = 10^k, one may determine k as
15536  //
15537  // k = ceil( log_10( 2^(alpha - e - 1) ) )
15538  // = ceil( (alpha - e - 1) * log_10(2) )
15539  //
15540  // From the paper:
15541  // "In theory the result of the procedure could be wrong since c is rounded,
15542  // and the computation itself is approximated [...]. In practice, however,
15543  // this simple function is sufficient."
15544  //
15545  // For IEEE double precision floating-point numbers converted into
15546  // normalized diyfp's w = f * 2^e, with q = 64,
15547  //
15548  // e >= -1022 (min IEEE exponent)
15549  // -52 (p - 1)
15550  // -52 (p - 1, possibly normalize denormal IEEE numbers)
15551  // -11 (normalize the diyfp)
15552  // = -1137
15553  //
15554  // and
15555  //
15556  // e <= +1023 (max IEEE exponent)
15557  // -52 (p - 1)
15558  // -11 (normalize the diyfp)
15559  // = 960
15560  //
15561  // This binary exponent range [-1137,960] results in a decimal exponent
15562  // range [-307,324]. One does not need to store a cached power for each
15563  // k in this range. For each such k it suffices to find a cached power
15564  // such that the exponent of the product lies in [alpha,gamma].
15565  // This implies that the difference of the decimal exponents of adjacent
15566  // table entries must be less than or equal to
15567  //
15568  // floor( (gamma - alpha) * log_10(2) ) = 8.
15569  //
15570  // (A smaller distance gamma-alpha would require a larger table.)
15571 
15572  // NB:
15573  // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
15574 
15575  constexpr int kCachedPowersMinDecExp = -300;
15576  constexpr int kCachedPowersDecStep = 8;
15577 
15578  static constexpr std::array<cached_power, 79> kCachedPowers =
15579  {
15580  {
15581  { 0xAB70FE17C79AC6CA, -1060, -300 },
15582  { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15583  { 0xBE5691EF416BD60C, -1007, -284 },
15584  { 0x8DD01FAD907FFC3C, -980, -276 },
15585  { 0xD3515C2831559A83, -954, -268 },
15586  { 0x9D71AC8FADA6C9B5, -927, -260 },
15587  { 0xEA9C227723EE8BCB, -901, -252 },
15588  { 0xAECC49914078536D, -874, -244 },
15589  { 0x823C12795DB6CE57, -847, -236 },
15590  { 0xC21094364DFB5637, -821, -228 },
15591  { 0x9096EA6F3848984F, -794, -220 },
15592  { 0xD77485CB25823AC7, -768, -212 },
15593  { 0xA086CFCD97BF97F4, -741, -204 },
15594  { 0xEF340A98172AACE5, -715, -196 },
15595  { 0xB23867FB2A35B28E, -688, -188 },
15596  { 0x84C8D4DFD2C63F3B, -661, -180 },
15597  { 0xC5DD44271AD3CDBA, -635, -172 },
15598  { 0x936B9FCEBB25C996, -608, -164 },
15599  { 0xDBAC6C247D62A584, -582, -156 },
15600  { 0xA3AB66580D5FDAF6, -555, -148 },
15601  { 0xF3E2F893DEC3F126, -529, -140 },
15602  { 0xB5B5ADA8AAFF80B8, -502, -132 },
15603  { 0x87625F056C7C4A8B, -475, -124 },
15604  { 0xC9BCFF6034C13053, -449, -116 },
15605  { 0x964E858C91BA2655, -422, -108 },
15606  { 0xDFF9772470297EBD, -396, -100 },
15607  { 0xA6DFBD9FB8E5B88F, -369, -92 },
15608  { 0xF8A95FCF88747D94, -343, -84 },
15609  { 0xB94470938FA89BCF, -316, -76 },
15610  { 0x8A08F0F8BF0F156B, -289, -68 },
15611  { 0xCDB02555653131B6, -263, -60 },
15612  { 0x993FE2C6D07B7FAC, -236, -52 },
15613  { 0xE45C10C42A2B3B06, -210, -44 },
15614  { 0xAA242499697392D3, -183, -36 },
15615  { 0xFD87B5F28300CA0E, -157, -28 },
15616  { 0xBCE5086492111AEB, -130, -20 },
15617  { 0x8CBCCC096F5088CC, -103, -12 },
15618  { 0xD1B71758E219652C, -77, -4 },
15619  { 0x9C40000000000000, -50, 4 },
15620  { 0xE8D4A51000000000, -24, 12 },
15621  { 0xAD78EBC5AC620000, 3, 20 },
15622  { 0x813F3978F8940984, 30, 28 },
15623  { 0xC097CE7BC90715B3, 56, 36 },
15624  { 0x8F7E32CE7BEA5C70, 83, 44 },
15625  { 0xD5D238A4ABE98068, 109, 52 },
15626  { 0x9F4F2726179A2245, 136, 60 },
15627  { 0xED63A231D4C4FB27, 162, 68 },
15628  { 0xB0DE65388CC8ADA8, 189, 76 },
15629  { 0x83C7088E1AAB65DB, 216, 84 },
15630  { 0xC45D1DF942711D9A, 242, 92 },
15631  { 0x924D692CA61BE758, 269, 100 },
15632  { 0xDA01EE641A708DEA, 295, 108 },
15633  { 0xA26DA3999AEF774A, 322, 116 },
15634  { 0xF209787BB47D6B85, 348, 124 },
15635  { 0xB454E4A179DD1877, 375, 132 },
15636  { 0x865B86925B9BC5C2, 402, 140 },
15637  { 0xC83553C5C8965D3D, 428, 148 },
15638  { 0x952AB45CFA97A0B3, 455, 156 },
15639  { 0xDE469FBD99A05FE3, 481, 164 },
15640  { 0xA59BC234DB398C25, 508, 172 },
15641  { 0xF6C69A72A3989F5C, 534, 180 },
15642  { 0xB7DCBF5354E9BECE, 561, 188 },
15643  { 0x88FCF317F22241E2, 588, 196 },
15644  { 0xCC20CE9BD35C78A5, 614, 204 },
15645  { 0x98165AF37B2153DF, 641, 212 },
15646  { 0xE2A0B5DC971F303A, 667, 220 },
15647  { 0xA8D9D1535CE3B396, 694, 228 },
15648  { 0xFB9B7CD9A4A7443C, 720, 236 },
15649  { 0xBB764C4CA7A44410, 747, 244 },
15650  { 0x8BAB8EEFB6409C1A, 774, 252 },
15651  { 0xD01FEF10A657842C, 800, 260 },
15652  { 0x9B10A4E5E9913129, 827, 268 },
15653  { 0xE7109BFBA19C0C9D, 853, 276 },
15654  { 0xAC2820D9623BF429, 880, 284 },
15655  { 0x80444B5E7AA7CF85, 907, 292 },
15656  { 0xBF21E44003ACDD2D, 933, 300 },
15657  { 0x8E679C2F5E44FF8F, 960, 308 },
15658  { 0xD433179D9C8CB841, 986, 316 },
15659  { 0x9E19DB92B4E31BA9, 1013, 324 },
15660  }
15661  };
15662 
15663  // This computation gives exactly the same results for k as
15664  // k = ceil((kAlpha - e - 1) * 0.30102999566398114)
15665  // for |e| <= 1500, but doesn't require floating-point operations.
15666  // NB: log_10(2) ~= 78913 / 2^18
15667  JSON_ASSERT(e >= -1500);
15668  JSON_ASSERT(e <= 1500);
15669  const int f = kAlpha - e - 1;
15670  const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
15671 
15672  const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15673  JSON_ASSERT(index >= 0);
15674  JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size());
15675 
15676  const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)];
15677  JSON_ASSERT(kAlpha <= cached.e + e + 64);
15678  JSON_ASSERT(kGamma >= cached.e + e + 64);
15679 
15680  return cached;
15681 }
15682 
15687 inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
15688 {
15689  // LCOV_EXCL_START
15690  if (n >= 1000000000)
15691  {
15692  pow10 = 1000000000;
15693  return 10;
15694  }
15695  // LCOV_EXCL_STOP
15696  if (n >= 100000000)
15697  {
15698  pow10 = 100000000;
15699  return 9;
15700  }
15701  if (n >= 10000000)
15702  {
15703  pow10 = 10000000;
15704  return 8;
15705  }
15706  if (n >= 1000000)
15707  {
15708  pow10 = 1000000;
15709  return 7;
15710  }
15711  if (n >= 100000)
15712  {
15713  pow10 = 100000;
15714  return 6;
15715  }
15716  if (n >= 10000)
15717  {
15718  pow10 = 10000;
15719  return 5;
15720  }
15721  if (n >= 1000)
15722  {
15723  pow10 = 1000;
15724  return 4;
15725  }
15726  if (n >= 100)
15727  {
15728  pow10 = 100;
15729  return 3;
15730  }
15731  if (n >= 10)
15732  {
15733  pow10 = 10;
15734  return 2;
15735  }
15736 
15737  pow10 = 1;
15738  return 1;
15739 }
15740 
15741 inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
15742  std::uint64_t rest, std::uint64_t ten_k)
15743 {
15744  JSON_ASSERT(len >= 1);
15745  JSON_ASSERT(dist <= delta);
15746  JSON_ASSERT(rest <= delta);
15747  JSON_ASSERT(ten_k > 0);
15748 
15749  // <--------------------------- delta ---->
15750  // <---- dist --------->
15751  // --------------[------------------+-------------------]--------------
15752  // M- w M+
15753  //
15754  // ten_k
15755  // <------>
15756  // <---- rest ---->
15757  // --------------[------------------+----+--------------]--------------
15758  // w V
15759  // = buf * 10^k
15760  //
15761  // ten_k represents a unit-in-the-last-place in the decimal representation
15762  // stored in buf.
15763  // Decrement buf by ten_k while this takes buf closer to w.
15764 
15765  // The tests are written in this order to avoid overflow in unsigned
15766  // integer arithmetic.
15767 
15768  while (rest < dist
15769  && delta - rest >= ten_k
15770  && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15771  {
15772  JSON_ASSERT(buf[len - 1] != '0');
15773  buf[len - 1]--;
15774  rest += ten_k;
15775  }
15776 }
15777 
15782 inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
15783  diyfp M_minus, diyfp w, diyfp M_plus)
15784 {
15785  static_assert(kAlpha >= -60, "internal error");
15786  static_assert(kGamma <= -32, "internal error");
15787 
15788  // Generates the digits (and the exponent) of a decimal floating-point
15789  // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's
15790  // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma.
15791  //
15792  // <--------------------------- delta ---->
15793  // <---- dist --------->
15794  // --------------[------------------+-------------------]--------------
15795  // M- w M+
15796  //
15797  // Grisu2 generates the digits of M+ from left to right and stops as soon as
15798  // V is in [M-,M+].
15799 
15800  JSON_ASSERT(M_plus.e >= kAlpha);
15801  JSON_ASSERT(M_plus.e <= kGamma);
15802 
15803  std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
15804  std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e)
15805 
15806  // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0):
15807  //
15808  // M+ = f * 2^e
15809  // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e
15810  // = ((p1 ) * 2^-e + (p2 )) * 2^e
15811  // = p1 + p2 * 2^e
15812 
15813  const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
15814 
15815  auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
15816  std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
15817 
15818  // 1)
15819  //
15820  // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0]
15821 
15822  JSON_ASSERT(p1 > 0);
15823 
15824  std::uint32_t pow10{};
15825  const int k = find_largest_pow10(p1, pow10);
15826 
15827  // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
15828  //
15829  // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1))
15830  // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1))
15831  //
15832  // M+ = p1 + p2 * 2^e
15833  // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e
15834  // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e
15835  // = d[k-1] * 10^(k-1) + ( rest) * 2^e
15836  //
15837  // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0)
15838  //
15839  // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0]
15840  //
15841  // but stop as soon as
15842  //
15843  // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e
15844 
15845  int n = k;
15846  while (n > 0)
15847  {
15848  // Invariants:
15849  // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k)
15850  // pow10 = 10^(n-1) <= p1 < 10^n
15851  //
15852  const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1)
15853  const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1)
15854  //
15855  // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e
15856  // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e)
15857  //
15858  JSON_ASSERT(d <= 9);
15859  buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
15860  //
15861  // M+ = buffer * 10^(n-1) + (r + p2 * 2^e)
15862  //
15863  p1 = r;
15864  n--;
15865  //
15866  // M+ = buffer * 10^n + (p1 + p2 * 2^e)
15867  // pow10 = 10^n
15868  //
15869 
15870  // Now check if enough digits have been generated.
15871  // Compute
15872  //
15873  // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e
15874  //
15875  // Note:
15876  // Since rest and delta share the same exponent e, it suffices to
15877  // compare the significands.
15878  const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15879  if (rest <= delta)
15880  {
15881  // V = buffer * 10^n, with M- <= V <= M+.
15882 
15883  decimal_exponent += n;
15884 
15885  // We may now just stop. But instead look if the buffer could be
15886  // decremented to bring V closer to w.
15887  //
15888  // pow10 = 10^n is now 1 ulp in the decimal representation V.
15889  // The rounding procedure works with diyfp's with an implicit
15890  // exponent of e.
15891  //
15892  // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
15893  //
15894  const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15895  grisu2_round(buffer, length, dist, delta, rest, ten_n);
15896 
15897  return;
15898  }
15899 
15900  pow10 /= 10;
15901  //
15902  // pow10 = 10^(n-1) <= p1 < 10^n
15903  // Invariants restored.
15904  }
15905 
15906  // 2)
15907  //
15908  // The digits of the integral part have been generated:
15909  //
15910  // M+ = d[k-1]...d[1]d[0] + p2 * 2^e
15911  // = buffer + p2 * 2^e
15912  //
15913  // Now generate the digits of the fractional part p2 * 2^e.
15914  //
15915  // Note:
15916  // No decimal point is generated: the exponent is adjusted instead.
15917  //
15918  // p2 actually represents the fraction
15919  //
15920  // p2 * 2^e
15921  // = p2 / 2^-e
15922  // = d[-1] / 10^1 + d[-2] / 10^2 + ...
15923  //
15924  // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...)
15925  //
15926  // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m
15927  // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...)
15928  //
15929  // using
15930  //
15931  // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e)
15932  // = ( d) * 2^-e + ( r)
15933  //
15934  // or
15935  // 10^m * p2 * 2^e = d + r * 2^e
15936  //
15937  // i.e.
15938  //
15939  // M+ = buffer + p2 * 2^e
15940  // = buffer + 10^-m * (d + r * 2^e)
15941  // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e
15942  //
15943  // and stop as soon as 10^-m * r * 2^e <= delta * 2^e
15944 
15945  JSON_ASSERT(p2 > delta);
15946 
15947  int m = 0;
15948  for (;;)
15949  {
15950  // Invariant:
15951  // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e
15952  // = buffer * 10^-m + 10^-m * (p2 ) * 2^e
15953  // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e
15954  // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
15955  //
15957  p2 *= 10;
15958  const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
15959  const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e
15960  //
15961  // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e
15962  // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e))
15963  // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e
15964  //
15965  JSON_ASSERT(d <= 9);
15966  buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
15967  //
15968  // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e
15969  //
15970  p2 = r;
15971  m++;
15972  //
15973  // M+ = buffer * 10^-m + 10^-m * p2 * 2^e
15974  // Invariant restored.
15975 
15976  // Check if enough digits have been generated.
15977  //
15978  // 10^-m * p2 * 2^e <= delta * 2^e
15979  // p2 * 2^e <= 10^m * delta * 2^e
15980  // p2 <= 10^m * delta
15981  delta *= 10;
15982  dist *= 10;
15983  if (p2 <= delta)
15984  {
15985  break;
15986  }
15987  }
15988 
15989  // V = buffer * 10^-m, with M- <= V <= M+.
15990 
15991  decimal_exponent -= m;
15992 
15993  // 1 ulp in the decimal representation is now 10^-m.
15994  // Since delta and dist are now scaled by 10^m, we need to do the
15995  // same with ulp in order to keep the units in sync.
15996  //
15997  // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e
15998  //
15999  const std::uint64_t ten_m = one.f;
16000  grisu2_round(buffer, length, dist, delta, p2, ten_m);
16001 
16002  // By construction this algorithm generates the shortest possible decimal
16003  // number (Loitsch, Theorem 6.2) which rounds back to w.
16004  // For an input number of precision p, at least
16005  //
16006  // N = 1 + ceil(p * log_10(2))
16007  //
16008  // decimal digits are sufficient to identify all binary floating-point
16009  // numbers (Matula, "In-and-Out conversions").
16010  // This implies that the algorithm does not produce more than N decimal
16011  // digits.
16012  //
16013  // N = 17 for p = 53 (IEEE double precision)
16014  // N = 9 for p = 24 (IEEE single precision)
16015 }
16016 
16023 inline void grisu2(char* buf, int& len, int& decimal_exponent,
16024  diyfp m_minus, diyfp v, diyfp m_plus)
16025 {
16026  JSON_ASSERT(m_plus.e == m_minus.e);
16027  JSON_ASSERT(m_plus.e == v.e);
16028 
16029  // --------(-----------------------+-----------------------)-------- (A)
16030  // m- v m+
16031  //
16032  // --------------------(-----------+-----------------------)-------- (B)
16033  // m- v m+
16034  //
16035  // First scale v (and m- and m+) such that the exponent is in the range
16036  // [alpha, gamma].
16037 
16038  const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
16039 
16040  const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k
16041 
16042  // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma]
16043  const diyfp w = diyfp::mul(v, c_minus_k);
16044  const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
16045  const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
16046 
16047  // ----(---+---)---------------(---+---)---------------(---+---)----
16048  // w- w w+
16049  // = c*m- = c*v = c*m+
16050  //
16051  // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and
16052  // w+ are now off by a small amount.
16053  // In fact:
16054  //
16055  // w - v * 10^k < 1 ulp
16056  //
16057  // To account for this inaccuracy, add resp. subtract 1 ulp.
16058  //
16059  // --------+---[---------------(---+---)---------------]---+--------
16060  // w- M- w M+ w+
16061  //
16062  // Now any number in [M-, M+] (bounds included) will round to w when input,
16063  // regardless of how the input rounding algorithm breaks ties.
16064  //
16065  // And digit_gen generates the shortest possible such number in [M-, M+].
16066  // Note that this does not mean that Grisu2 always generates the shortest
16067  // possible number in the interval (m-, m+).
16068  const diyfp M_minus(w_minus.f + 1, w_minus.e);
16069  const diyfp M_plus (w_plus.f - 1, w_plus.e );
16070 
16071  decimal_exponent = -cached.k; // = -(-k) = k
16072 
16073  grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
16074 }
16075 
16081 template<typename FloatType>
16083 void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
16084 {
16085  static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
16086  "internal error: not enough precision");
16087 
16088  JSON_ASSERT(std::isfinite(value));
16089  JSON_ASSERT(value > 0);
16090 
16091  // If the neighbors (and boundaries) of 'value' are always computed for double-precision
16092  // numbers, all float's can be recovered using strtod (and strtof). However, the resulting
16093  // decimal representations are not exactly "short".
16094  //
16095  // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars)
16096  // says "value is converted to a string as if by std::sprintf in the default ("C") locale"
16097  // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars'
16098  // does.
16099  // On the other hand, the documentation for 'std::to_chars' requires that "parsing the
16100  // representation using the corresponding std::from_chars function recovers value exactly". That
16101  // indicates that single precision floating-point numbers should be recovered using
16102  // 'std::strtof'.
16103  //
16104  // NB: If the neighbors are computed for single-precision numbers, there is a single float
16105  // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
16106  // value is off by 1 ulp.
16107 #if 0
16108  const boundaries w = compute_boundaries(static_cast<double>(value));
16109 #else
16110  const boundaries w = compute_boundaries(value);
16111 #endif
16112 
16113  grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
16114 }
16115 
16123 inline char* append_exponent(char* buf, int e)
16124 {
16125  JSON_ASSERT(e > -1000);
16126  JSON_ASSERT(e < 1000);
16127 
16128  if (e < 0)
16129  {
16130  e = -e;
16131  *buf++ = '-';
16132  }
16133  else
16134  {
16135  *buf++ = '+';
16136  }
16137 
16138  auto k = static_cast<std::uint32_t>(e);
16139  if (k < 10)
16140  {
16141  // Always print at least two digits in the exponent.
16142  // This is for compatibility with printf("%g").
16143  *buf++ = '0';
16144  *buf++ = static_cast<char>('0' + k);
16145  }
16146  else if (k < 100)
16147  {
16148  *buf++ = static_cast<char>('0' + k / 10);
16149  k %= 10;
16150  *buf++ = static_cast<char>('0' + k);
16151  }
16152  else
16153  {
16154  *buf++ = static_cast<char>('0' + k / 100);
16155  k %= 100;
16156  *buf++ = static_cast<char>('0' + k / 10);
16157  k %= 10;
16158  *buf++ = static_cast<char>('0' + k);
16159  }
16160 
16161  return buf;
16162 }
16163 
16175 inline char* format_buffer(char* buf, int len, int decimal_exponent,
16176  int min_exp, int max_exp)
16177 {
16178  JSON_ASSERT(min_exp < 0);
16179  JSON_ASSERT(max_exp > 0);
16180 
16181  const int k = len;
16182  const int n = len + decimal_exponent;
16183 
16184  // v = buf * 10^(n-k)
16185  // k is the length of the buffer (number of decimal digits)
16186  // n is the position of the decimal point relative to the start of the buffer.
16187 
16188  if (k <= n && n <= max_exp)
16189  {
16190  // digits[000]
16191  // len <= max_exp + 2
16192 
16193  std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
16194  // Make it look like a floating-point number (#362, #378)
16195  buf[n + 0] = '.';
16196  buf[n + 1] = '0';
16197  return buf + (static_cast<size_t>(n) + 2);
16198  }
16199 
16200  if (0 < n && n <= max_exp)
16201  {
16202  // dig.its
16203  // len <= max_digits10 + 1
16204 
16205  JSON_ASSERT(k > n);
16206 
16207  std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
16208  buf[n] = '.';
16209  return buf + (static_cast<size_t>(k) + 1U);
16210  }
16211 
16212  if (min_exp < n && n <= 0)
16213  {
16214  // 0.[000]digits
16215  // len <= 2 + (-min_exp - 1) + max_digits10
16216 
16217  std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
16218  buf[0] = '0';
16219  buf[1] = '.';
16220  std::memset(buf + 2, '0', static_cast<size_t>(-n));
16221  return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
16222  }
16223 
16224  if (k == 1)
16225  {
16226  // dE+123
16227  // len <= 1 + 5
16228 
16229  buf += 1;
16230  }
16231  else
16232  {
16233  // d.igitsE+123
16234  // len <= max_digits10 + 1 + 5
16235 
16236  std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
16237  buf[1] = '.';
16238  buf += 1 + static_cast<size_t>(k);
16239  }
16240 
16241  *buf++ = 'e';
16242  return append_exponent(buf, n - 1);
16243 }
16244 
16245 } // namespace dtoa_impl
16246 
16257 template<typename FloatType>
16260 char* to_chars(char* first, const char* last, FloatType value)
16261 {
16262  static_cast<void>(last); // maybe unused - fix warning
16263  JSON_ASSERT(std::isfinite(value));
16264 
16265  // Use signbit(value) instead of (value < 0) since signbit works for -0.
16266  if (std::signbit(value))
16267  {
16268  value = -value;
16269  *first++ = '-';
16270  }
16271 
16272 #ifdef __GNUC__
16273 #pragma GCC diagnostic push
16274 #pragma GCC diagnostic ignored "-Wfloat-equal"
16275 #endif
16276  if (value == 0) // +-0
16277  {
16278  *first++ = '0';
16279  // Make it look like a floating-point number (#362, #378)
16280  *first++ = '.';
16281  *first++ = '0';
16282  return first;
16283  }
16284 #ifdef __GNUC__
16285 #pragma GCC diagnostic pop
16286 #endif
16287 
16288  JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
16289 
16290  // Compute v = buffer * 10^decimal_exponent.
16291  // The decimal digits are stored in the buffer, which needs to be interpreted
16292  // as an unsigned decimal integer.
16293  // len is the length of the buffer, i.e. the number of decimal digits.
16294  int len = 0;
16295  int decimal_exponent = 0;
16296  dtoa_impl::grisu2(first, len, decimal_exponent, value);
16297 
16298  JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16299 
16300  // Format the buffer like printf("%.*g", prec, value)
16301  constexpr int kMinExp = -4;
16302  // Use digits10 here to increase compatibility with version 2.
16303  constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
16304 
16305  JSON_ASSERT(last - first >= kMaxExp + 2);
16306  JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16307  JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16308 
16309  return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
16310 }
16311 
16312 } // namespace detail
16313 } // namespace nlohmann
16314 
16315 // #include <nlohmann/detail/exceptions.hpp>
16316 
16317 // #include <nlohmann/detail/macro_scope.hpp>
16318 
16319 // #include <nlohmann/detail/meta/cpp_future.hpp>
16320 
16321 // #include <nlohmann/detail/output/binary_writer.hpp>
16322 
16323 // #include <nlohmann/detail/output/output_adapters.hpp>
16324 
16325 // #include <nlohmann/detail/value_t.hpp>
16326 
16327 
16328 namespace nlohmann
16329 {
16330 namespace detail
16331 {
16333 // serialization //
16335 
16338 {
16339  strict,
16340  replace,
16341  ignore
16342 };
16343 
16344 template<typename BasicJsonType>
16346 {
16347  using string_t = typename BasicJsonType::string_t;
16348  using number_float_t = typename BasicJsonType::number_float_t;
16349  using number_integer_t = typename BasicJsonType::number_integer_t;
16350  using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
16351  using binary_char_t = typename BasicJsonType::binary_t::value_type;
16352  static constexpr std::uint8_t UTF8_ACCEPT = 0;
16353  static constexpr std::uint8_t UTF8_REJECT = 1;
16354 
16355  public:
16361  serializer(output_adapter_t<char> s, const char ichar,
16362  error_handler_t error_handler_ = error_handler_t::strict)
16363  : o(std::move(s))
16364  , loc(std::localeconv())
16365  , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
16366  , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point)))
16367  , indent_char(ichar)
16368  , indent_string(512, indent_char)
16369  , error_handler(error_handler_)
16370  {}
16371 
16372  // delete because of pointer members
16373  serializer(const serializer&) = delete;
16374  serializer& operator=(const serializer&) = delete;
16375  serializer(serializer&&) = delete;
16376  serializer& operator=(serializer&&) = delete;
16377  ~serializer() = default;
16378 
16401  void dump(const BasicJsonType& val,
16402  const bool pretty_print,
16403  const bool ensure_ascii,
16404  const unsigned int indent_step,
16405  const unsigned int current_indent = 0)
16406  {
16407  switch (val.m_type)
16408  {
16409  case value_t::object:
16410  {
16411  if (val.m_value.object->empty())
16412  {
16413  o->write_characters("{}", 2);
16414  return;
16415  }
16416 
16417  if (pretty_print)
16418  {
16419  o->write_characters("{\n", 2);
16420 
16421  // variable to hold indentation for recursive calls
16422  const auto new_indent = current_indent + indent_step;
16423  if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
16424  {
16425  indent_string.resize(indent_string.size() * 2, ' ');
16426  }
16427 
16428  // first n-1 elements
16429  auto i = val.m_value.object->cbegin();
16430  for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16431  {
16432  o->write_characters(indent_string.c_str(), new_indent);
16433  o->write_character('\"');
16434  dump_escaped(i->first, ensure_ascii);
16435  o->write_characters("\": ", 3);
16436  dump(i->second, true, ensure_ascii, indent_step, new_indent);
16437  o->write_characters(",\n", 2);
16438  }
16439 
16440  // last element
16441  JSON_ASSERT(i != val.m_value.object->cend());
16442  JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16443  o->write_characters(indent_string.c_str(), new_indent);
16444  o->write_character('\"');
16445  dump_escaped(i->first, ensure_ascii);
16446  o->write_characters("\": ", 3);
16447  dump(i->second, true, ensure_ascii, indent_step, new_indent);
16448 
16449  o->write_character('\n');
16450  o->write_characters(indent_string.c_str(), current_indent);
16451  o->write_character('}');
16452  }
16453  else
16454  {
16455  o->write_character('{');
16456 
16457  // first n-1 elements
16458  auto i = val.m_value.object->cbegin();
16459  for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16460  {
16461  o->write_character('\"');
16462  dump_escaped(i->first, ensure_ascii);
16463  o->write_characters("\":", 2);
16464  dump(i->second, false, ensure_ascii, indent_step, current_indent);
16465  o->write_character(',');
16466  }
16467 
16468  // last element
16469  JSON_ASSERT(i != val.m_value.object->cend());
16470  JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16471  o->write_character('\"');
16472  dump_escaped(i->first, ensure_ascii);
16473  o->write_characters("\":", 2);
16474  dump(i->second, false, ensure_ascii, indent_step, current_indent);
16475 
16476  o->write_character('}');
16477  }
16478 
16479  return;
16480  }
16481 
16482  case value_t::array:
16483  {
16484  if (val.m_value.array->empty())
16485  {
16486  o->write_characters("[]", 2);
16487  return;
16488  }
16489 
16490  if (pretty_print)
16491  {
16492  o->write_characters("[\n", 2);
16493 
16494  // variable to hold indentation for recursive calls
16495  const auto new_indent = current_indent + indent_step;
16496  if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
16497  {
16498  indent_string.resize(indent_string.size() * 2, ' ');
16499  }
16500 
16501  // first n-1 elements
16502  for (auto i = val.m_value.array->cbegin();
16503  i != val.m_value.array->cend() - 1; ++i)
16504  {
16505  o->write_characters(indent_string.c_str(), new_indent);
16506  dump(*i, true, ensure_ascii, indent_step, new_indent);
16507  o->write_characters(",\n", 2);
16508  }
16509 
16510  // last element
16511  JSON_ASSERT(!val.m_value.array->empty());
16512  o->write_characters(indent_string.c_str(), new_indent);
16513  dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
16514 
16515  o->write_character('\n');
16516  o->write_characters(indent_string.c_str(), current_indent);
16517  o->write_character(']');
16518  }
16519  else
16520  {
16521  o->write_character('[');
16522 
16523  // first n-1 elements
16524  for (auto i = val.m_value.array->cbegin();
16525  i != val.m_value.array->cend() - 1; ++i)
16526  {
16527  dump(*i, false, ensure_ascii, indent_step, current_indent);
16528  o->write_character(',');
16529  }
16530 
16531  // last element
16532  JSON_ASSERT(!val.m_value.array->empty());
16533  dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
16534 
16535  o->write_character(']');
16536  }
16537 
16538  return;
16539  }
16540 
16541  case value_t::string:
16542  {
16543  o->write_character('\"');
16544  dump_escaped(*val.m_value.string, ensure_ascii);
16545  o->write_character('\"');
16546  return;
16547  }
16548 
16549  case value_t::binary:
16550  {
16551  if (pretty_print)
16552  {
16553  o->write_characters("{\n", 2);
16554 
16555  // variable to hold indentation for recursive calls
16556  const auto new_indent = current_indent + indent_step;
16557  if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
16558  {
16559  indent_string.resize(indent_string.size() * 2, ' ');
16560  }
16561 
16562  o->write_characters(indent_string.c_str(), new_indent);
16563 
16564  o->write_characters("\"bytes\": [", 10);
16565 
16566  if (!val.m_value.binary->empty())
16567  {
16568  for (auto i = val.m_value.binary->cbegin();
16569  i != val.m_value.binary->cend() - 1; ++i)
16570  {
16571  dump_integer(*i);
16572  o->write_characters(", ", 2);
16573  }
16574  dump_integer(val.m_value.binary->back());
16575  }
16576 
16577  o->write_characters("],\n", 3);
16578  o->write_characters(indent_string.c_str(), new_indent);
16579 
16580  o->write_characters("\"subtype\": ", 11);
16581  if (val.m_value.binary->has_subtype())
16582  {
16583  dump_integer(val.m_value.binary->subtype());
16584  }
16585  else
16586  {
16587  o->write_characters("null", 4);
16588  }
16589  o->write_character('\n');
16590  o->write_characters(indent_string.c_str(), current_indent);
16591  o->write_character('}');
16592  }
16593  else
16594  {
16595  o->write_characters("{\"bytes\":[", 10);
16596 
16597  if (!val.m_value.binary->empty())
16598  {
16599  for (auto i = val.m_value.binary->cbegin();
16600  i != val.m_value.binary->cend() - 1; ++i)
16601  {
16602  dump_integer(*i);
16603  o->write_character(',');
16604  }
16605  dump_integer(val.m_value.binary->back());
16606  }
16607 
16608  o->write_characters("],\"subtype\":", 12);
16609  if (val.m_value.binary->has_subtype())
16610  {
16611  dump_integer(val.m_value.binary->subtype());
16612  o->write_character('}');
16613  }
16614  else
16615  {
16616  o->write_characters("null}", 5);
16617  }
16618  }
16619  return;
16620  }
16621 
16622  case value_t::boolean:
16623  {
16624  if (val.m_value.boolean)
16625  {
16626  o->write_characters("true", 4);
16627  }
16628  else
16629  {
16630  o->write_characters("false", 5);
16631  }
16632  return;
16633  }
16634 
16636  {
16637  dump_integer(val.m_value.number_integer);
16638  return;
16639  }
16640 
16642  {
16643  dump_integer(val.m_value.number_unsigned);
16644  return;
16645  }
16646 
16647  case value_t::number_float:
16648  {
16649  dump_float(val.m_value.number_float);
16650  return;
16651  }
16652 
16653  case value_t::discarded:
16654  {
16655  o->write_characters("<discarded>", 11);
16656  return;
16657  }
16658 
16659  case value_t::null:
16660  {
16661  o->write_characters("null", 4);
16662  return;
16663  }
16664 
16665  default: // LCOV_EXCL_LINE
16666  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
16667  }
16668  }
16669 
16685  void dump_escaped(const string_t& s, const bool ensure_ascii)
16686  {
16687  std::uint32_t codepoint{};
16688  std::uint8_t state = UTF8_ACCEPT;
16689  std::size_t bytes = 0; // number of bytes written to string_buffer
16690 
16691  // number of bytes written at the point of the last valid byte
16692  std::size_t bytes_after_last_accept = 0;
16693  std::size_t undumped_chars = 0;
16694 
16695  for (std::size_t i = 0; i < s.size(); ++i)
16696  {
16697  const auto byte = static_cast<std::uint8_t>(s[i]);
16698 
16699  switch (decode(state, codepoint, byte))
16700  {
16701  case UTF8_ACCEPT: // decode found a new code point
16702  {
16703  switch (codepoint)
16704  {
16705  case 0x08: // backspace
16706  {
16707  string_buffer[bytes++] = '\\';
16708  string_buffer[bytes++] = 'b';
16709  break;
16710  }
16711 
16712  case 0x09: // horizontal tab
16713  {
16714  string_buffer[bytes++] = '\\';
16715  string_buffer[bytes++] = 't';
16716  break;
16717  }
16718 
16719  case 0x0A: // newline
16720  {
16721  string_buffer[bytes++] = '\\';
16722  string_buffer[bytes++] = 'n';
16723  break;
16724  }
16725 
16726  case 0x0C: // formfeed
16727  {
16728  string_buffer[bytes++] = '\\';
16729  string_buffer[bytes++] = 'f';
16730  break;
16731  }
16732 
16733  case 0x0D: // carriage return
16734  {
16735  string_buffer[bytes++] = '\\';
16736  string_buffer[bytes++] = 'r';
16737  break;
16738  }
16739 
16740  case 0x22: // quotation mark
16741  {
16742  string_buffer[bytes++] = '\\';
16743  string_buffer[bytes++] = '\"';
16744  break;
16745  }
16746 
16747  case 0x5C: // reverse solidus
16748  {
16749  string_buffer[bytes++] = '\\';
16750  string_buffer[bytes++] = '\\';
16751  break;
16752  }
16753 
16754  default:
16755  {
16756  // escape control characters (0x00..0x1F) or, if
16757  // ensure_ascii parameter is used, non-ASCII characters
16758  if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
16759  {
16760  if (codepoint <= 0xFFFF)
16761  {
16762  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
16763  (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
16764  static_cast<std::uint16_t>(codepoint));
16765  bytes += 6;
16766  }
16767  else
16768  {
16769  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
16770  (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
16771  static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
16772  static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
16773  bytes += 12;
16774  }
16775  }
16776  else
16777  {
16778  // copy byte to buffer (all previous bytes
16779  // been copied have in default case above)
16780  string_buffer[bytes++] = s[i];
16781  }
16782  break;
16783  }
16784  }
16785 
16786  // write buffer and reset index; there must be 13 bytes
16787  // left, as this is the maximal number of bytes to be
16788  // written ("\uxxxx\uxxxx\0") for one code point
16789  if (string_buffer.size() - bytes < 13)
16790  {
16791  o->write_characters(string_buffer.data(), bytes);
16792  bytes = 0;
16793  }
16794 
16795  // remember the byte position of this accept
16797  undumped_chars = 0;
16798  break;
16799  }
16800 
16801  case UTF8_REJECT: // decode found invalid UTF-8 byte
16802  {
16803  switch (error_handler)
16804  {
16806  {
16807  std::string sn(9, '\0');
16808  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
16809  (std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
16810  JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn, BasicJsonType()));
16811  }
16812 
16815  {
16816  // in case we saw this character the first time, we
16817  // would like to read it again, because the byte
16818  // may be OK for itself, but just not OK for the
16819  // previous sequence
16820  if (undumped_chars > 0)
16821  {
16822  --i;
16823  }
16824 
16825  // reset length buffer to the last accepted index;
16826  // thus removing/ignoring the invalid characters
16828 
16830  {
16831  // add a replacement character
16832  if (ensure_ascii)
16833  {
16834  string_buffer[bytes++] = '\\';
16835  string_buffer[bytes++] = 'u';
16836  string_buffer[bytes++] = 'f';
16837  string_buffer[bytes++] = 'f';
16838  string_buffer[bytes++] = 'f';
16839  string_buffer[bytes++] = 'd';
16840  }
16841  else
16842  {
16846  }
16847 
16848  // write buffer and reset index; there must be 13 bytes
16849  // left, as this is the maximal number of bytes to be
16850  // written ("\uxxxx\uxxxx\0") for one code point
16851  if (string_buffer.size() - bytes < 13)
16852  {
16853  o->write_characters(string_buffer.data(), bytes);
16854  bytes = 0;
16855  }
16856 
16858  }
16859 
16860  undumped_chars = 0;
16861 
16862  // continue processing the string
16863  state = UTF8_ACCEPT;
16864  break;
16865  }
16866 
16867  default: // LCOV_EXCL_LINE
16868  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
16869  }
16870  break;
16871  }
16872 
16873  default: // decode found yet incomplete multi-byte code point
16874  {
16875  if (!ensure_ascii)
16876  {
16877  // code point will not be escaped - copy byte to buffer
16878  string_buffer[bytes++] = s[i];
16879  }
16880  ++undumped_chars;
16881  break;
16882  }
16883  }
16884  }
16885 
16886  // we finished processing the string
16888  {
16889  // write buffer
16890  if (bytes > 0)
16891  {
16892  o->write_characters(string_buffer.data(), bytes);
16893  }
16894  }
16895  else
16896  {
16897  // we finish reading, but do not accept: string was incomplete
16898  switch (error_handler)
16899  {
16901  {
16902  std::string sn(9, '\0');
16903  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
16904  (std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
16905  JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn, BasicJsonType()));
16906  }
16907 
16909  {
16910  // write all accepted bytes
16911  o->write_characters(string_buffer.data(), bytes_after_last_accept);
16912  break;
16913  }
16914 
16916  {
16917  // write all accepted bytes
16918  o->write_characters(string_buffer.data(), bytes_after_last_accept);
16919  // add a replacement character
16920  if (ensure_ascii)
16921  {
16922  o->write_characters("\\ufffd", 6);
16923  }
16924  else
16925  {
16926  o->write_characters("\xEF\xBF\xBD", 3);
16927  }
16928  break;
16929  }
16930 
16931  default: // LCOV_EXCL_LINE
16932  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
16933  }
16934  }
16935  }
16936 
16937  private:
16946  inline unsigned int count_digits(number_unsigned_t x) noexcept
16947  {
16948  unsigned int n_digits = 1;
16949  for (;;)
16950  {
16951  if (x < 10)
16952  {
16953  return n_digits;
16954  }
16955  if (x < 100)
16956  {
16957  return n_digits + 1;
16958  }
16959  if (x < 1000)
16960  {
16961  return n_digits + 2;
16962  }
16963  if (x < 10000)
16964  {
16965  return n_digits + 3;
16966  }
16967  x = x / 10000u;
16968  n_digits += 4;
16969  }
16970  }
16971 
16981  template < typename NumberType, detail::enable_if_t <
16986  int > = 0 >
16987  void dump_integer(NumberType x)
16988  {
16989  static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16990  {
16991  {
16992  {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}},
16993  {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}},
16994  {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}},
16995  {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}},
16996  {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}},
16997  {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}},
16998  {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}},
16999  {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}},
17000  {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}},
17001  {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}},
17002  }
17003  };
17004 
17005  // special case for "0"
17006  if (x == 0)
17007  {
17008  o->write_character('0');
17009  return;
17010  }
17011 
17012  // use a pointer to fill the buffer
17013  auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg)
17014 
17015  const bool is_negative = std::is_signed<NumberType>::value && !(x >= 0); // see issue #755
17016  number_unsigned_t abs_value;
17017 
17018  unsigned int n_chars{};
17019 
17020  if (is_negative)
17021  {
17022  *buffer_ptr = '-';
17023  abs_value = remove_sign(static_cast<number_integer_t>(x));
17024 
17025  // account one more byte for the minus sign
17026  n_chars = 1 + count_digits(abs_value);
17027  }
17028  else
17029  {
17030  abs_value = static_cast<number_unsigned_t>(x);
17031  n_chars = count_digits(abs_value);
17032  }
17033 
17034  // spare 1 byte for '\0'
17035  JSON_ASSERT(n_chars < number_buffer.size() - 1);
17036 
17037  // jump to the end to generate the string from backward
17038  // so we later avoid reversing the result
17039  buffer_ptr += n_chars;
17040 
17041  // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu
17042  // See: https://www.youtube.com/watch?v=o4-CwDo2zpg
17043  while (abs_value >= 100)
17044  {
17045  const auto digits_index = static_cast<unsigned>((abs_value % 100));
17046  abs_value /= 100;
17047  *(--buffer_ptr) = digits_to_99[digits_index][1];
17048  *(--buffer_ptr) = digits_to_99[digits_index][0];
17049  }
17050 
17051  if (abs_value >= 10)
17052  {
17053  const auto digits_index = static_cast<unsigned>(abs_value);
17054  *(--buffer_ptr) = digits_to_99[digits_index][1];
17055  *(--buffer_ptr) = digits_to_99[digits_index][0];
17056  }
17057  else
17058  {
17059  *(--buffer_ptr) = static_cast<char>('0' + abs_value);
17060  }
17061 
17062  o->write_characters(number_buffer.data(), n_chars);
17063  }
17064 
17073  void dump_float(number_float_t x)
17074  {
17075  // NaN / inf
17076  if (!std::isfinite(x))
17077  {
17078  o->write_characters("null", 4);
17079  return;
17080  }
17081 
17082  // If number_float_t is an IEEE-754 single or double precision number,
17083  // use the Grisu2 algorithm to produce short numbers which are
17084  // guaranteed to round-trip, using strtof and strtod, resp.
17085  //
17086  // NB: The test below works if <long double> == <double>.
17087  static constexpr bool is_ieee_single_or_double
17088  = (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) ||
17089  (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);
17090 
17091  dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
17092  }
17093 
17094  void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
17095  {
17096  auto* begin = number_buffer.data();
17097  auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
17098 
17099  o->write_characters(begin, static_cast<size_t>(end - begin));
17100  }
17101 
17102  void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
17103  {
17104  // get number of digits for a float -> text -> float round-trip
17105  static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
17106 
17107  // the actual conversion
17108  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
17109  std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
17110 
17111  // negative value indicates an error
17112  JSON_ASSERT(len > 0);
17113  // check if buffer was large enough
17114  JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
17115 
17116  // erase thousands separator
17117  if (thousands_sep != '\0')
17118  {
17119  auto* const end = std::remove(number_buffer.begin(),
17120  number_buffer.begin() + len, thousands_sep);
17121  std::fill(end, number_buffer.end(), '\0');
17122  JSON_ASSERT((end - number_buffer.begin()) <= len);
17123  len = (end - number_buffer.begin());
17124  }
17125 
17126  // convert decimal point to '.'
17127  if (decimal_point != '\0' && decimal_point != '.')
17128  {
17129  auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
17130  if (dec_pos != number_buffer.end())
17131  {
17132  *dec_pos = '.';
17133  }
17134  }
17135 
17136  o->write_characters(number_buffer.data(), static_cast<std::size_t>(len));
17137 
17138  // determine if need to append ".0"
17139  const bool value_is_int_like =
17140  std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
17141  [](char c)
17142  {
17143  return c == '.' || c == 'e';
17144  });
17145 
17146  if (value_is_int_like)
17147  {
17148  o->write_characters(".0", 2);
17149  }
17150  }
17151 
17173  static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
17174  {
17175  static const std::array<std::uint8_t, 400> utf8d =
17176  {
17177  {
17178  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, // 00..1F
17179  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, // 20..3F
17180  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, // 40..5F
17181  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, // 60..7F
17182  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, // 80..9F
17183  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, // A0..BF
17184  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, // C0..DF
17185  0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF
17186  0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF
17187  0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0
17188  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, // s1..s2
17189  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, // s3..s4
17190  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, // s5..s6
17191  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 // s7..s8
17192  }
17193  };
17194 
17195  JSON_ASSERT(byte < utf8d.size());
17196  const std::uint8_t type = utf8d[byte];
17197 
17198  codep = (state != UTF8_ACCEPT)
17199  ? (byte & 0x3fu) | (codep << 6u)
17200  : (0xFFu >> type) & (byte);
17201 
17202  std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
17203  JSON_ASSERT(index < 400);
17204  state = utf8d[index];
17205  return state;
17206  }
17207 
17208  /*
17209  * Overload to make the compiler happy while it is instantiating
17210  * dump_integer for number_unsigned_t.
17211  * Must never be called.
17212  */
17214  {
17215  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
17216  return x; // LCOV_EXCL_LINE
17217  }
17218 
17219  /*
17220  * Helper function for dump_integer
17221  *
17222  * This function takes a negative signed integer and returns its absolute
17223  * value as unsigned integer. The plus/minus shuffling is necessary as we can
17224  * not directly remove the sign of an arbitrary signed integer as the
17225  * absolute values of INT_MIN and INT_MAX are usually not the same. See
17226  * #1708 for details.
17227  */
17228  inline number_unsigned_t remove_sign(number_integer_t x) noexcept
17229  {
17230  JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)()); // NOLINT(misc-redundant-expression)
17231  return static_cast<number_unsigned_t>(-(x + 1)) + 1;
17232  }
17233 
17234  private:
17236  output_adapter_t<char> o = nullptr;
17237 
17239  std::array<char, 64> number_buffer{{}};
17240 
17242  const std::lconv* loc = nullptr;
17244  const char thousands_sep = '\0';
17246  const char decimal_point = '\0';
17247 
17249  std::array<char, 512> string_buffer{{}};
17250 
17252  const char indent_char;
17255 
17258 };
17259 } // namespace detail
17260 } // namespace nlohmann
17261 
17262 // #include <nlohmann/detail/value_t.hpp>
17263 
17264 // #include <nlohmann/json_fwd.hpp>
17265 
17266 // #include <nlohmann/ordered_map.hpp>
17267 
17268 
17269 #include <functional> // less
17270 #include <initializer_list> // initializer_list
17271 #include <iterator> // input_iterator_tag, iterator_traits
17272 #include <memory> // allocator
17273 #include <stdexcept> // for out_of_range
17274 #include <type_traits> // enable_if, is_convertible
17275 #include <utility> // pair
17276 #include <vector> // vector
17277 
17278 // #include <nlohmann/detail/macro_scope.hpp>
17279 
17280 
17281 namespace nlohmann
17282 {
17283 
17286 template <class Key, class T, class IgnoredLess = std::less<Key>,
17287  class Allocator = std::allocator<std::pair<const Key, T>>>
17288  struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
17289 {
17290  using key_type = Key;
17291  using mapped_type = T;
17292  using Container = std::vector<std::pair<const Key, T>, Allocator>;
17293  using typename Container::iterator;
17294  using typename Container::const_iterator;
17295  using typename Container::size_type;
17296  using typename Container::value_type;
17297 
17298  // Explicit constructors instead of `using Container::Container`
17299  // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
17300  ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {}
17301  template <class It>
17302  ordered_map(It first, It last, const Allocator& alloc = Allocator())
17303  : Container{first, last, alloc} {}
17304  ordered_map(std::initializer_list<T> init, const Allocator& alloc = Allocator() )
17305  : Container{init, alloc} {}
17306 
17307  std::pair<iterator, bool> emplace(const key_type& key, T&& t)
17308  {
17309  for (auto it = this->begin(); it != this->end(); ++it)
17310  {
17311  if (it->first == key)
17312  {
17313  return {it, false};
17314  }
17315  }
17316  Container::emplace_back(key, t);
17317  return {--this->end(), true};
17318  }
17319 
17320  T& operator[](const Key& key)
17321  {
17322  return emplace(key, T{}).first->second;
17323  }
17324 
17325  const T& operator[](const Key& key) const
17326  {
17327  return at(key);
17328  }
17329 
17330  T& at(const Key& key)
17331  {
17332  for (auto it = this->begin(); it != this->end(); ++it)
17333  {
17334  if (it->first == key)
17335  {
17336  return it->second;
17337  }
17338  }
17339 
17340  JSON_THROW(std::out_of_range("key not found"));
17341  }
17342 
17343  const T& at(const Key& key) const
17344  {
17345  for (auto it = this->begin(); it != this->end(); ++it)
17346  {
17347  if (it->first == key)
17348  {
17349  return it->second;
17350  }
17351  }
17352 
17353  JSON_THROW(std::out_of_range("key not found"));
17354  }
17355 
17356  size_type erase(const Key& key)
17357  {
17358  for (auto it = this->begin(); it != this->end(); ++it)
17359  {
17360  if (it->first == key)
17361  {
17362  // Since we cannot move const Keys, re-construct them in place
17363  for (auto next = it; ++next != this->end(); ++it)
17364  {
17365  it->~value_type(); // Destroy but keep allocation
17366  new (&*it) value_type{std::move(*next)};
17367  }
17368  Container::pop_back();
17369  return 1;
17370  }
17371  }
17372  return 0;
17373  }
17374 
17375  iterator erase(iterator pos)
17376  {
17377  auto it = pos;
17378 
17379  // Since we cannot move const Keys, re-construct them in place
17380  for (auto next = it; ++next != this->end(); ++it)
17381  {
17382  it->~value_type(); // Destroy but keep allocation
17383  new (&*it) value_type{std::move(*next)};
17384  }
17385  Container::pop_back();
17386  return pos;
17387  }
17388 
17389  size_type count(const Key& key) const
17390  {
17391  for (auto it = this->begin(); it != this->end(); ++it)
17392  {
17393  if (it->first == key)
17394  {
17395  return 1;
17396  }
17397  }
17398  return 0;
17399  }
17400 
17401  iterator find(const Key& key)
17402  {
17403  for (auto it = this->begin(); it != this->end(); ++it)
17404  {
17405  if (it->first == key)
17406  {
17407  return it;
17408  }
17409  }
17410  return Container::end();
17411  }
17412 
17413  const_iterator find(const Key& key) const
17414  {
17415  for (auto it = this->begin(); it != this->end(); ++it)
17416  {
17417  if (it->first == key)
17418  {
17419  return it;
17420  }
17421  }
17422  return Container::end();
17423  }
17424 
17425  std::pair<iterator, bool> insert( value_type&& value )
17426  {
17427  return emplace(value.first, std::move(value.second));
17428  }
17429 
17430  std::pair<iterator, bool> insert( const value_type& value )
17431  {
17432  for (auto it = this->begin(); it != this->end(); ++it)
17433  {
17434  if (it->first == value.first)
17435  {
17436  return {it, false};
17437  }
17438  }
17439  Container::push_back(value);
17440  return {--this->end(), true};
17441  }
17442 
17443  template<typename InputIt>
17444  using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17445  std::input_iterator_tag>::value>::type;
17446 
17447  template<typename InputIt, typename = require_input_iter<InputIt>>
17448  void insert(InputIt first, InputIt last)
17449  {
17450  for (auto it = first; it != last; ++it)
17451  {
17452  insert(*it);
17453  }
17454  }
17455 };
17456 
17457 } // namespace nlohmann
17458 
17459 
17460 #if defined(JSON_HAS_CPP_17)
17461  #include <string_view>
17462 #endif
17463 
17469 namespace nlohmann
17470 {
17471 
17557 class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
17558 {
17559  private:
17560  template<detail::value_t> friend struct detail::external_constructor;
17561  friend ::nlohmann::json_pointer<basic_json>;
17562 
17563  template<typename BasicJsonType, typename InputType>
17565  friend ::nlohmann::detail::serializer<basic_json>;
17566  template<typename BasicJsonType>
17567  friend class ::nlohmann::detail::iter_impl;
17568  template<typename BasicJsonType, typename CharType>
17569  friend class ::nlohmann::detail::binary_writer;
17570  template<typename BasicJsonType, typename InputType, typename SAX>
17571  friend class ::nlohmann::detail::binary_reader;
17572  template<typename BasicJsonType>
17573  friend class ::nlohmann::detail::json_sax_dom_parser;
17574  template<typename BasicJsonType>
17575  friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17576  friend class ::nlohmann::detail::exception;
17577 
17580 
17582  // convenience aliases for types residing in namespace detail;
17584 
17585  template<typename InputAdapterType>
17586  static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
17587  InputAdapterType adapter,
17589  const bool allow_exceptions = true,
17590  const bool ignore_comments = false
17591  )
17592  {
17593  return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
17594  std::move(cb), allow_exceptions, ignore_comments);
17595  }
17596 
17597  private:
17599  template<typename BasicJsonType>
17601  template<typename BasicJsonType>
17603  template<typename Iterator>
17606 
17607  template<typename CharType>
17609 
17610  template<typename InputType>
17613 
17616 
17617  public:
17621  template<typename T, typename SFINAE>
17622  using json_serializer = JSONSerializer<T, SFINAE>;
17628  using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
17629 
17633 
17635  // exceptions //
17637 
17641 
17654 
17656 
17657 
17659  // container types //
17661 
17666 
17669 
17673  using const_reference = const value_type&;
17674 
17676  using difference_type = std::ptrdiff_t;
17678  using size_type = std::size_t;
17679 
17681  using allocator_type = AllocatorType<basic_json>;
17682 
17684  using pointer = typename std::allocator_traits<allocator_type>::pointer;
17686  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
17687 
17696 
17698 
17699 
17704  {
17705  return allocator_type();
17706  }
17707 
17735  static basic_json meta()
17736  {
17738 
17739  result["copyright"] = "(C) 2013-2021 Niels Lohmann";
17740  result["name"] = "JSON for Modern C++";
17741  result["url"] = "https://github.com/nlohmann/json";
17742  result["version"]["string"] =
17746  result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
17747  result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
17748  result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
17749 
17750 #ifdef _WIN32
17751  result["platform"] = "win32";
17752 #elif defined __linux__
17753  result["platform"] = "linux";
17754 #elif defined __APPLE__
17755  result["platform"] = "apple";
17756 #elif defined __unix__
17757  result["platform"] = "unix";
17758 #else
17759  result["platform"] = "unknown";
17760 #endif
17761 
17762 #if defined(__ICC) || defined(__INTEL_COMPILER)
17763  result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}};
17764 #elif defined(__clang__)
17765  result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}};
17766 #elif defined(__GNUC__) || defined(__GNUG__)
17767  result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}};
17768 #elif defined(__HP_cc) || defined(__HP_aCC)
17769  result["compiler"] = "hp"
17770 #elif defined(__IBMCPP__)
17771  result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
17772 #elif defined(_MSC_VER)
17773  result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
17774 #elif defined(__PGI)
17775  result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
17776 #elif defined(__SUNPRO_CC)
17777  result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}};
17778 #else
17779  result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
17780 #endif
17781 
17782 #ifdef __cplusplus
17783  result["compiler"]["c++"] = std::to_string(__cplusplus);
17784 #else
17785  result["compiler"]["c++"] = "unknown";
17786 #endif
17787  return result;
17788  }
17789 
17790 
17792  // JSON value data types //
17794 
17799 
17800 #if defined(JSON_HAS_CPP_14)
17801  // Use transparent comparator if possible, combined with perfect forwarding
17802  // on find() and count() calls prevents unnecessary string construction.
17803  using object_comparator_t = std::less<>;
17804 #else
17805  using object_comparator_t = std::less<StringType>;
17806 #endif
17807 
17891  using object_t = ObjectType<StringType,
17892  basic_json,
17894  AllocatorType<std::pair<const StringType,
17896 
17941  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17942 
17994  using string_t = StringType;
17995 
18020  using boolean_t = BooleanType;
18021 
18092  using number_integer_t = NumberIntegerType;
18093 
18163  using number_unsigned_t = NumberUnsignedType;
18164 
18231  using number_float_t = NumberFloatType;
18232 
18304 
18305  private:
18306 
18308  template<typename T, typename... Args>
18310  static T* create(Args&& ... args)
18311  {
18312  AllocatorType<T> alloc;
18313  using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18314 
18315  auto deleter = [&](T * obj)
18316  {
18317  AllocatorTraits::deallocate(alloc, obj, 1);
18318  };
18319  std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18320  AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18321  JSON_ASSERT(obj != nullptr);
18322  return obj.release();
18323  }
18324 
18326  // JSON value storage //
18328 
18355  union json_value
18356  {
18373 
18375  json_value() = default;
18377  json_value(boolean_t v) noexcept : boolean(v) {}
18386  {
18387  switch (t)
18388  {
18389  case value_t::object:
18390  {
18391  object = create<object_t>();
18392  break;
18393  }
18394 
18395  case value_t::array:
18396  {
18397  array = create<array_t>();
18398  break;
18399  }
18400 
18401  case value_t::string:
18402  {
18403  string = create<string_t>("");
18404  break;
18405  }
18406 
18407  case value_t::binary:
18408  {
18409  binary = create<binary_t>();
18410  break;
18411  }
18412 
18413  case value_t::boolean:
18414  {
18415  boolean = boolean_t(false);
18416  break;
18417  }
18418 
18420  {
18422  break;
18423  }
18424 
18426  {
18428  break;
18429  }
18430 
18431  case value_t::number_float:
18432  {
18434  break;
18435  }
18436 
18437  case value_t::null:
18438  {
18439  object = nullptr; // silence warning, see #821
18440  break;
18441  }
18442 
18443  case value_t::discarded:
18444  default:
18445  {
18446  object = nullptr; // silence warning, see #821
18448  {
18449  JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.0", basic_json())); // LCOV_EXCL_LINE
18450  }
18451  break;
18452  }
18453  }
18454  }
18455 
18458  {
18459  string = create<string_t>(value);
18460  }
18461 
18464  {
18465  string = create<string_t>(std::move(value));
18466  }
18467 
18470  {
18471  object = create<object_t>(value);
18472  }
18473 
18476  {
18477  object = create<object_t>(std::move(value));
18478  }
18479 
18482  {
18483  array = create<array_t>(value);
18484  }
18485 
18488  {
18489  array = create<array_t>(std::move(value));
18490  }
18491 
18494  {
18495  binary = create<binary_t>(value);
18496  }
18497 
18500  {
18501  binary = create<binary_t>(std::move(value));
18502  }
18503 
18506  {
18507  binary = create<binary_t>(value);
18508  }
18509 
18512  {
18513  binary = create<binary_t>(std::move(value));
18514  }
18515 
18517  {
18518  if (t == value_t::array || t == value_t::object)
18519  {
18520  // flatten the current json_value to a heap-allocated stack
18521  std::vector<basic_json> stack;
18522 
18523  // move the top-level items to stack
18524  if (t == value_t::array)
18525  {
18526  stack.reserve(array->size());
18527  std::move(array->begin(), array->end(), std::back_inserter(stack));
18528  }
18529  else
18530  {
18531  stack.reserve(object->size());
18532  for (auto&& it : *object)
18533  {
18534  stack.push_back(std::move(it.second));
18535  }
18536  }
18537 
18538  while (!stack.empty())
18539  {
18540  // move the last item to local variable to be processed
18541  basic_json current_item(std::move(stack.back()));
18542  stack.pop_back();
18543 
18544  // if current_item is array/object, move
18545  // its children to the stack to be processed later
18546  if (current_item.is_array())
18547  {
18548  std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
18549 
18550  current_item.m_value.array->clear();
18551  }
18552  else if (current_item.is_object())
18553  {
18554  for (auto&& it : *current_item.m_value.object)
18555  {
18556  stack.push_back(std::move(it.second));
18557  }
18558 
18559  current_item.m_value.object->clear();
18560  }
18561 
18562  // it's now safe that current_item get destructed
18563  // since it doesn't have any children
18564  }
18565  }
18566 
18567  switch (t)
18568  {
18569  case value_t::object:
18570  {
18571  AllocatorType<object_t> alloc;
18572  std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
18573  std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
18574  break;
18575  }
18576 
18577  case value_t::array:
18578  {
18579  AllocatorType<array_t> alloc;
18580  std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
18581  std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
18582  break;
18583  }
18584 
18585  case value_t::string:
18586  {
18587  AllocatorType<string_t> alloc;
18588  std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
18589  std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
18590  break;
18591  }
18592 
18593  case value_t::binary:
18594  {
18595  AllocatorType<binary_t> alloc;
18596  std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
18597  std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
18598  break;
18599  }
18600 
18601  case value_t::null:
18602  case value_t::boolean:
18605  case value_t::number_float:
18606  case value_t::discarded:
18607  default:
18608  {
18609  break;
18610  }
18611  }
18612  }
18613  };
18614 
18615  private:
18634  void assert_invariant(bool check_parents = true) const noexcept
18635  {
18636  JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr);
18637  JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr);
18638  JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr);
18639  JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr);
18640 
18641 #if JSON_DIAGNOSTICS
18642  JSON_TRY
18643  {
18644  // cppcheck-suppress assertWithSideEffect
18645  JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j)
18646  {
18647  return j.m_parent == this;
18648  }));
18649  }
18650  JSON_CATCH(...) {} // LCOV_EXCL_LINE
18651 #endif
18652  static_cast<void>(check_parents);
18653  }
18654 
18656  {
18657 #if JSON_DIAGNOSTICS
18658  switch (m_type)
18659  {
18660  case value_t::array:
18661  {
18662  for (auto& element : *m_value.array)
18663  {
18664  element.m_parent = this;
18665  }
18666  break;
18667  }
18668 
18669  case value_t::object:
18670  {
18671  for (auto& element : *m_value.object)
18672  {
18673  element.second.m_parent = this;
18674  }
18675  break;
18676  }
18677 
18678  case value_t::null:
18679  case value_t::string:
18680  case value_t::boolean:
18683  case value_t::number_float:
18684  case value_t::binary:
18685  case value_t::discarded:
18686  default:
18687  break;
18688  }
18689 #endif
18690  }
18691 
18693  {
18694 #if JSON_DIAGNOSTICS
18695  for (typename iterator::difference_type i = 0; i < count; ++i)
18696  {
18697  (it + i)->m_parent = this;
18698  }
18699 #else
18700  static_cast<void>(count);
18701 #endif
18702  return it;
18703  }
18704 
18705  reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1))
18706  {
18707 #if JSON_DIAGNOSTICS
18708  if (old_capacity != std::size_t(-1))
18709  {
18710  // see https://github.com/nlohmann/json/issues/2838
18712  if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity))
18713  {
18714  // capacity has changed: update all parents
18715  set_parents();
18716  return j;
18717  }
18718  }
18719 
18720  j.m_parent = this;
18721 #else
18722  static_cast<void>(j);
18723  static_cast<void>(old_capacity);
18724 #endif
18725  return j;
18726  }
18727 
18728  public:
18730  // JSON parser callback //
18732 
18749 
18800 
18802  // constructors //
18804 
18809 
18841  : m_type(v), m_value(v)
18842  {
18843  assert_invariant();
18844  }
18845 
18864  basic_json(std::nullptr_t = nullptr) noexcept
18865  : basic_json(value_t::null)
18866  {
18867  assert_invariant();
18868  }
18869 
18932  template < typename CompatibleType,
18933  typename U = detail::uncvref_t<CompatibleType>,
18936  basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape)
18937  JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
18938  std::forward<CompatibleType>(val))))
18939  {
18940  JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
18941  set_parents();
18942  assert_invariant();
18943  }
18944 
18971  template < typename BasicJsonType,
18974  basic_json(const BasicJsonType& val)
18975  {
18976  using other_boolean_t = typename BasicJsonType::boolean_t;
18977  using other_number_float_t = typename BasicJsonType::number_float_t;
18978  using other_number_integer_t = typename BasicJsonType::number_integer_t;
18979  using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t;
18980  using other_string_t = typename BasicJsonType::string_t;
18981  using other_object_t = typename BasicJsonType::object_t;
18982  using other_array_t = typename BasicJsonType::array_t;
18983  using other_binary_t = typename BasicJsonType::binary_t;
18984 
18985  switch (val.type())
18986  {
18987  case value_t::boolean:
18988  JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>());
18989  break;
18990  case value_t::number_float:
18991  JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>());
18992  break;
18994  JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>());
18995  break;
18997  JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>());
18998  break;
18999  case value_t::string:
19000  JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t&>());
19001  break;
19002  case value_t::object:
19003  JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t&>());
19004  break;
19005  case value_t::array:
19006  JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>());
19007  break;
19008  case value_t::binary:
19009  JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t&>());
19010  break;
19011  case value_t::null:
19012  *this = nullptr;
19013  break;
19014  case value_t::discarded:
19015  m_type = value_t::discarded;
19016  break;
19017  default: // LCOV_EXCL_LINE
19018  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
19019  }
19020  set_parents();
19021  assert_invariant();
19022  }
19023 
19099  bool type_deduction = true,
19100  value_t manual_type = value_t::array)
19101  {
19102  // check if each element is an array with two elements whose first
19103  // element is a string
19104  bool is_an_object = std::all_of(init.begin(), init.end(),
19105  [](const detail::json_ref<basic_json>& element_ref)
19106  {
19107  return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19108  });
19109 
19110  // adjust type if type deduction is not wanted
19111  if (!type_deduction)
19112  {
19113  // if array is wanted, do not create an object though possible
19114  if (manual_type == value_t::array)
19115  {
19116  is_an_object = false;
19117  }
19118 
19119  // if object is wanted but impossible, throw an exception
19120  if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object))
19121  {
19122  JSON_THROW(type_error::create(301, "cannot create object from initializer list", basic_json()));
19123  }
19124  }
19125 
19126  if (is_an_object)
19127  {
19128  // the initializer list is a list of pairs -> create object
19129  m_type = value_t::object;
19131 
19132  for (auto& element_ref : init)
19133  {
19134  auto element = element_ref.moved_or_copied();
19135  m_value.object->emplace(
19136  std::move(*((*element.m_value.array)[0].m_value.string)),
19137  std::move((*element.m_value.array)[1]));
19138  }
19139  }
19140  else
19141  {
19142  // the initializer list describes an array -> create array
19143  m_type = value_t::array;
19144  m_value.array = create<array_t>(init.begin(), init.end());
19145  }
19146 
19147  set_parents();
19148  assert_invariant();
19149  }
19150 
19180  {
19181  auto res = basic_json();
19182  res.m_type = value_t::binary;
19183  res.m_value = init;
19184  return res;
19185  }
19186 
19216  static basic_json binary(const typename binary_t::container_type& init, typename binary_t::subtype_type subtype)
19217  {
19218  auto res = basic_json();
19219  res.m_type = value_t::binary;
19220  res.m_value = binary_t(init, subtype);
19221  return res;
19222  }
19223 
19227  {
19228  auto res = basic_json();
19229  res.m_type = value_t::binary;
19230  res.m_value = std::move(init);
19231  return res;
19232  }
19233 
19237  {
19238  auto res = basic_json();
19239  res.m_type = value_t::binary;
19240  res.m_value = binary_t(std::move(init), subtype);
19241  return res;
19242  }
19243 
19283  {
19284  return basic_json(init, false, value_t::array);
19285  }
19286 
19327  {
19328  return basic_json(init, false, value_t::object);
19329  }
19330 
19354  : m_type(value_t::array)
19355  {
19356  m_value.array = create<array_t>(cnt, val);
19357  set_parents();
19358  assert_invariant();
19359  }
19360 
19416  template < class InputIT, typename std::enable_if <
19419  basic_json(InputIT first, InputIT last)
19420  {
19421  JSON_ASSERT(first.m_object != nullptr);
19422  JSON_ASSERT(last.m_object != nullptr);
19423 
19424  // make sure iterator fits the current value
19425  if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
19426  {
19427  JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", basic_json()));
19428  }
19429 
19430  // copy type from first iterator
19431  m_type = first.m_object->m_type;
19432 
19433  // check if iterator range is complete for primitive values
19434  switch (m_type)
19435  {
19436  case value_t::boolean:
19437  case value_t::number_float:
19440  case value_t::string:
19441  {
19442  if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin()
19443  || !last.m_it.primitive_iterator.is_end()))
19444  {
19445  JSON_THROW(invalid_iterator::create(204, "iterators out of range", *first.m_object));
19446  }
19447  break;
19448  }
19449 
19450  case value_t::null:
19451  case value_t::object:
19452  case value_t::array:
19453  case value_t::binary:
19454  case value_t::discarded:
19455  default:
19456  break;
19457  }
19458 
19459  switch (m_type)
19460  {
19462  {
19463  m_value.number_integer = first.m_object->m_value.number_integer;
19464  break;
19465  }
19466 
19468  {
19469  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19470  break;
19471  }
19472 
19473  case value_t::number_float:
19474  {
19475  m_value.number_float = first.m_object->m_value.number_float;
19476  break;
19477  }
19478 
19479  case value_t::boolean:
19480  {
19481  m_value.boolean = first.m_object->m_value.boolean;
19482  break;
19483  }
19484 
19485  case value_t::string:
19486  {
19487  m_value = *first.m_object->m_value.string;
19488  break;
19489  }
19490 
19491  case value_t::object:
19492  {
19493  m_value.object = create<object_t>(first.m_it.object_iterator,
19494  last.m_it.object_iterator);
19495  break;
19496  }
19497 
19498  case value_t::array:
19499  {
19500  m_value.array = create<array_t>(first.m_it.array_iterator,
19501  last.m_it.array_iterator);
19502  break;
19503  }
19504 
19505  case value_t::binary:
19506  {
19507  m_value = *first.m_object->m_value.binary;
19508  break;
19509  }
19510 
19511  case value_t::null:
19512  case value_t::discarded:
19513  default:
19514  JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object));
19515  }
19516 
19517  set_parents();
19518  assert_invariant();
19519  }
19520 
19521 
19523  // other constructors and destructor //
19525 
19526  template<typename JsonRef,
19528  std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
19529  basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
19530 
19556  basic_json(const basic_json& other)
19557  : m_type(other.m_type)
19558  {
19559  // check of passed value is valid
19560  other.assert_invariant();
19561 
19562  switch (m_type)
19563  {
19564  case value_t::object:
19565  {
19566  m_value = *other.m_value.object;
19567  break;
19568  }
19569 
19570  case value_t::array:
19571  {
19572  m_value = *other.m_value.array;
19573  break;
19574  }
19575 
19576  case value_t::string:
19577  {
19578  m_value = *other.m_value.string;
19579  break;
19580  }
19581 
19582  case value_t::boolean:
19583  {
19584  m_value = other.m_value.boolean;
19585  break;
19586  }
19587 
19589  {
19590  m_value = other.m_value.number_integer;
19591  break;
19592  }
19593 
19595  {
19596  m_value = other.m_value.number_unsigned;
19597  break;
19598  }
19599 
19600  case value_t::number_float:
19601  {
19602  m_value = other.m_value.number_float;
19603  break;
19604  }
19605 
19606  case value_t::binary:
19607  {
19608  m_value = *other.m_value.binary;
19609  break;
19610  }
19611 
19612  case value_t::null:
19613  case value_t::discarded:
19614  default:
19615  break;
19616  }
19617 
19618  set_parents();
19619  assert_invariant();
19620  }
19621 
19648  basic_json(basic_json&& other) noexcept
19649  : m_type(std::move(other.m_type)),
19650  m_value(std::move(other.m_value))
19651  {
19652  // check that passed value is valid
19653  other.assert_invariant(false);
19654 
19655  // invalidate payload
19656  other.m_type = value_t::null;
19657  other.m_value = {};
19658 
19659  set_parents();
19660  assert_invariant();
19661  }
19662 
19686  basic_json& operator=(basic_json other) noexcept (
19691  )
19692  {
19693  // check that passed value is valid
19694  other.assert_invariant();
19695 
19696  using std::swap;
19697  swap(m_type, other.m_type);
19698  swap(m_value, other.m_value);
19699 
19700  set_parents();
19701  assert_invariant();
19702  return *this;
19703  }
19704 
19720  ~basic_json() noexcept
19721  {
19722  assert_invariant(false);
19723  m_value.destroy(m_type);
19724  }
19725 
19727 
19728  public:
19730  // object inspection //
19732 
19736 
19784  string_t dump(const int indent = -1,
19785  const char indent_char = ' ',
19786  const bool ensure_ascii = false,
19787  const error_handler_t error_handler = error_handler_t::strict) const
19788  {
19789  string_t result;
19790  serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
19791 
19792  if (indent >= 0)
19793  {
19794  s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent));
19795  }
19796  else
19797  {
19798  s.dump(*this, false, ensure_ascii, 0);
19799  }
19800 
19801  return result;
19802  }
19803 
19837  constexpr value_t type() const noexcept
19838  {
19839  return m_type;
19840  }
19841 
19868  constexpr bool is_primitive() const noexcept
19869  {
19870  return is_null() || is_string() || is_boolean() || is_number() || is_binary();
19871  }
19872 
19895  constexpr bool is_structured() const noexcept
19896  {
19897  return is_array() || is_object();
19898  }
19899 
19917  constexpr bool is_null() const noexcept
19918  {
19919  return m_type == value_t::null;
19920  }
19921 
19939  constexpr bool is_boolean() const noexcept
19940  {
19941  return m_type == value_t::boolean;
19942  }
19943 
19969  constexpr bool is_number() const noexcept
19970  {
19971  return is_number_integer() || is_number_float();
19972  }
19973 
19998  constexpr bool is_number_integer() const noexcept
19999  {
20000  return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20001  }
20002 
20026  constexpr bool is_number_unsigned() const noexcept
20027  {
20028  return m_type == value_t::number_unsigned;
20029  }
20030 
20054  constexpr bool is_number_float() const noexcept
20055  {
20056  return m_type == value_t::number_float;
20057  }
20058 
20076  constexpr bool is_object() const noexcept
20077  {
20078  return m_type == value_t::object;
20079  }
20080 
20098  constexpr bool is_array() const noexcept
20099  {
20100  return m_type == value_t::array;
20101  }
20102 
20120  constexpr bool is_string() const noexcept
20121  {
20122  return m_type == value_t::string;
20123  }
20124 
20142  constexpr bool is_binary() const noexcept
20143  {
20144  return m_type == value_t::binary;
20145  }
20146 
20169  constexpr bool is_discarded() const noexcept
20170  {
20171  return m_type == value_t::discarded;
20172  }
20173 
20195  constexpr operator value_t() const noexcept
20196  {
20197  return m_type;
20198  }
20199 
20201 
20202  private:
20204  // value access //
20206 
20208  boolean_t get_impl(boolean_t* /*unused*/) const
20209  {
20211  {
20212  return m_value.boolean;
20213  }
20214 
20215  JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()), *this));
20216  }
20217 
20219  object_t* get_impl_ptr(object_t* /*unused*/) noexcept
20220  {
20221  return is_object() ? m_value.object : nullptr;
20222  }
20223 
20225  constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept
20226  {
20227  return is_object() ? m_value.object : nullptr;
20228  }
20229 
20231  array_t* get_impl_ptr(array_t* /*unused*/) noexcept
20232  {
20233  return is_array() ? m_value.array : nullptr;
20234  }
20235 
20237  constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept
20238  {
20239  return is_array() ? m_value.array : nullptr;
20240  }
20241 
20243  string_t* get_impl_ptr(string_t* /*unused*/) noexcept
20244  {
20245  return is_string() ? m_value.string : nullptr;
20246  }
20247 
20249  constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept
20250  {
20251  return is_string() ? m_value.string : nullptr;
20252  }
20253 
20255  boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept
20256  {
20257  return is_boolean() ? &m_value.boolean : nullptr;
20258  }
20259 
20261  constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept
20262  {
20263  return is_boolean() ? &m_value.boolean : nullptr;
20264  }
20265 
20268  {
20269  return is_number_integer() ? &m_value.number_integer : nullptr;
20270  }
20271 
20273  constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept
20274  {
20275  return is_number_integer() ? &m_value.number_integer : nullptr;
20276  }
20277 
20280  {
20281  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
20282  }
20283 
20285  constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept
20286  {
20287  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
20288  }
20289 
20292  {
20293  return is_number_float() ? &m_value.number_float : nullptr;
20294  }
20295 
20297  constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept
20298  {
20299  return is_number_float() ? &m_value.number_float : nullptr;
20300  }
20301 
20303  binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept
20304  {
20305  return is_binary() ? m_value.binary : nullptr;
20306  }
20307 
20309  constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept
20310  {
20311  return is_binary() ? m_value.binary : nullptr;
20312  }
20313 
20325  template<typename ReferenceType, typename ThisType>
20326  static ReferenceType get_ref_impl(ThisType& obj)
20327  {
20328  // delegate the call to get_ptr<>()
20330 
20331  if (JSON_HEDLEY_LIKELY(ptr != nullptr))
20332  {
20333  return *ptr;
20334  }
20335 
20336  JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj));
20337  }
20338 
20339  public:
20343 
20370  template<typename PointerType, typename std::enable_if<
20372  auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
20373  {
20374  // delegate the call to get_impl_ptr<>()
20375  return get_impl_ptr(static_cast<PointerType>(nullptr));
20376  }
20377 
20382  template < typename PointerType, typename std::enable_if <
20385  constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
20386  {
20387  // delegate the call to get_impl_ptr<>() const
20388  return get_impl_ptr(static_cast<PointerType>(nullptr));
20389  }
20390 
20391  private:
20430  template < typename ValueType,
20434  int > = 0 >
20435  ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept(
20436  JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20437  {
20438  ValueType ret{};
20440  return ret;
20441  }
20442 
20473  template < typename ValueType,
20476  int > = 0 >
20477  ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(
20478  JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20479  {
20481  }
20482 
20498  template < typename BasicJsonType,
20501  int > = 0 >
20502  BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const
20503  {
20504  return *this;
20505  }
20506 
20521  template<typename BasicJsonType,
20524  int> = 0>
20526  {
20527  return *this;
20528  }
20529 
20534  template<typename PointerType,
20537  int> = 0>
20538  constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept
20539  -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20540  {
20541  // delegate the call to get_ptr
20542  return get_ptr<PointerType>();
20543  }
20544 
20545  public:
20569  template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
20570 #if defined(JSON_HAS_CPP_14)
20571  constexpr
20572 #endif
20573  auto get() const noexcept(
20574  noexcept(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
20575  -> decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))
20576  {
20577  // we cannot static_assert on ValueTypeCV being non-const, because
20578  // there is support for get<const basic_json_t>(), which is why we
20579  // still need the uncvref
20581  "get() cannot be used with reference types, you might want to use get_ref()");
20582  return get_impl<ValueType>(detail::priority_tag<4> {});
20583  }
20584 
20612  template<typename PointerType, typename std::enable_if<
20614  auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
20615  {
20616  // delegate the call to get_ptr
20617  return get_ptr<PointerType>();
20618  }
20619 
20653  template < typename ValueType,
20657  int > = 0 >
20658  ValueType & get_to(ValueType& v) const noexcept(noexcept(
20659  JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
20660  {
20662  return v;
20663  }
20664 
20665  // specialization to allow to call get_to with a basic_json value
20666  // see https://github.com/nlohmann/json/issues/2175
20667  template<typename ValueType,
20670  int> = 0>
20671  ValueType & get_to(ValueType& v) const
20672  {
20673  v = *this;
20674  return v;
20675  }
20676 
20677  template <
20678  typename T, std::size_t N,
20679  typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
20682  Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
20683  noexcept(noexcept(JSONSerializer<Array>::from_json(
20684  std::declval<const basic_json_t&>(), v)))
20685  {
20687  return v;
20688  }
20689 
20716  template<typename ReferenceType, typename std::enable_if<
20718  ReferenceType get_ref()
20719  {
20720  // delegate call to get_ref_impl
20721  return get_ref_impl<ReferenceType>(*this);
20722  }
20723 
20728  template < typename ReferenceType, typename std::enable_if <
20731  ReferenceType get_ref() const
20732  {
20733  // delegate call to get_ref_impl
20734  return get_ref_impl<ReferenceType>(*this);
20735  }
20736 
20766  template < typename ValueType, typename std::enable_if <
20773 
20774 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20776 #endif
20778  >::value, int >::type = 0 >
20779  JSON_EXPLICIT operator ValueType() const
20780  {
20781  // delegate the call to get<>() const
20782  return get<ValueType>();
20783  }
20784 
20795  {
20796  if (!is_binary())
20797  {
20798  JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this));
20799  }
20800 
20801  return *get_ptr<binary_t*>();
20802  }
20803 
20805  const binary_t& get_binary() const
20806  {
20807  if (!is_binary())
20808  {
20809  JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this));
20810  }
20811 
20812  return *get_ptr<const binary_t*>();
20813  }
20814 
20816 
20817 
20819  // element access //
20821 
20825 
20853  {
20854  // at only works for arrays
20856  {
20857  JSON_TRY
20858  {
20859  return set_parent(m_value.array->at(idx));
20860  }
20861  JSON_CATCH (std::out_of_range&)
20862  {
20863  // create better exception explanation
20864  JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
20865  }
20866  }
20867  else
20868  {
20869  JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
20870  }
20871  }
20872 
20900  {
20901  // at only works for arrays
20903  {
20904  JSON_TRY
20905  {
20906  return m_value.array->at(idx);
20907  }
20908  JSON_CATCH (std::out_of_range&)
20909  {
20910  // create better exception explanation
20911  JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
20912  }
20913  }
20914  else
20915  {
20916  JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
20917  }
20918  }
20919 
20950  reference at(const typename object_t::key_type& key)
20951  {
20952  // at only works for objects
20954  {
20955  JSON_TRY
20956  {
20957  return set_parent(m_value.object->at(key));
20958  }
20959  JSON_CATCH (std::out_of_range&)
20960  {
20961  // create better exception explanation
20962  JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this));
20963  }
20964  }
20965  else
20966  {
20967  JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
20968  }
20969  }
20970 
21001  const_reference at(const typename object_t::key_type& key) const
21002  {
21003  // at only works for objects
21005  {
21006  JSON_TRY
21007  {
21008  return m_value.object->at(key);
21009  }
21010  JSON_CATCH (std::out_of_range&)
21011  {
21012  // create better exception explanation
21013  JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this));
21014  }
21015  }
21016  else
21017  {
21018  JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
21019  }
21020  }
21021 
21048  {
21049  // implicitly convert null value to an empty array
21050  if (is_null())
21051  {
21052  m_type = value_t::array;
21053  m_value.array = create<array_t>();
21054  assert_invariant();
21055  }
21056 
21057  // operator[] only works for arrays
21059  {
21060  // fill up array with null values if given idx is outside range
21061  if (idx >= m_value.array->size())
21062  {
21063 #if JSON_DIAGNOSTICS
21064  // remember array size before resizing
21065  const auto previous_size = m_value.array->size();
21066 #endif
21067  m_value.array->resize(idx + 1);
21068 
21069 #if JSON_DIAGNOSTICS
21070  // set parent for values added above
21071  set_parents(begin() + static_cast<typename iterator::difference_type>(previous_size), static_cast<typename iterator::difference_type>(idx + 1 - previous_size));
21072 #endif
21073  }
21074 
21075  return m_value.array->operator[](idx);
21076  }
21077 
21078  JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this));
21079  }
21080 
21101  {
21102  // const operator[] only works for arrays
21104  {
21105  return m_value.array->operator[](idx);
21106  }
21107 
21108  JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this));
21109  }
21110 
21138  reference operator[](const typename object_t::key_type& key)
21139  {
21140  // implicitly convert null value to an empty object
21141  if (is_null())
21142  {
21143  m_type = value_t::object;
21144  m_value.object = create<object_t>();
21145  assert_invariant();
21146  }
21147 
21148  // operator[] only works for objects
21150  {
21151  return set_parent(m_value.object->operator[](key));
21152  }
21153 
21154  JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
21155  }
21156 
21187  const_reference operator[](const typename object_t::key_type& key) const
21188  {
21189  // const operator[] only works for objects
21191  {
21192  JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
21193  return m_value.object->find(key)->second;
21194  }
21195 
21196  JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
21197  }
21198 
21226  template<typename T>
21228  reference operator[](T* key)
21229  {
21230  // implicitly convert null to object
21231  if (is_null())
21232  {
21233  m_type = value_t::object;
21235  assert_invariant();
21236  }
21237 
21238  // at only works for objects
21240  {
21241  return set_parent(m_value.object->operator[](key));
21242  }
21243 
21244  JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
21245  }
21246 
21277  template<typename T>
21279  const_reference operator[](T* key) const
21280  {
21281  // at only works for objects
21283  {
21284  JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
21285  return m_value.object->find(key)->second;
21286  }
21287 
21288  JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
21289  }
21290 
21341  // using std::is_convertible in a std::enable_if will fail when using explicit conversions
21342  template < class ValueType, typename std::enable_if <
21345  ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
21346  {
21347  // at only works for objects
21349  {
21350  // if key is found, return value and given default value otherwise
21351  const auto it = find(key);
21352  if (it != end())
21353  {
21354  return it->template get<ValueType>();
21355  }
21356 
21357  return default_value;
21358  }
21359 
21360  JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this));
21361  }
21362 
21367  string_t value(const typename object_t::key_type& key, const char* default_value) const
21368  {
21369  return value(key, string_t(default_value));
21370  }
21371 
21415  template<class ValueType, typename std::enable_if<
21417  ValueType value(const json_pointer& ptr, const ValueType& default_value) const
21418  {
21419  // at only works for objects
21421  {
21422  // if pointer resolves a value, return it or use default value
21423  JSON_TRY
21424  {
21425  return ptr.get_checked(this).template get<ValueType>();
21426  }
21428  {
21429  return default_value;
21430  }
21431  }
21432 
21433  JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this));
21434  }
21435 
21441  string_t value(const json_pointer& ptr, const char* default_value) const
21442  {
21443  return value(ptr, string_t(default_value));
21444  }
21445 
21472  {
21473  return *begin();
21474  }
21475 
21480  {
21481  return *cbegin();
21482  }
21483 
21516  {
21517  auto tmp = end();
21518  --tmp;
21519  return *tmp;
21520  }
21521 
21526  {
21527  auto tmp = cend();
21528  --tmp;
21529  return *tmp;
21530  }
21531 
21578  template < class IteratorType, typename std::enable_if <
21581  = 0 >
21582  IteratorType erase(IteratorType pos)
21583  {
21584  // make sure iterator fits the current value
21585  if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
21586  {
21587  JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
21588  }
21589 
21590  IteratorType result = end();
21591 
21592  switch (m_type)
21593  {
21594  case value_t::boolean:
21595  case value_t::number_float:
21598  case value_t::string:
21599  case value_t::binary:
21600  {
21601  if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin()))
21602  {
21603  JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this));
21604  }
21605 
21606  if (is_string())
21607  {
21608  AllocatorType<string_t> alloc;
21609  std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21610  std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21611  m_value.string = nullptr;
21612  }
21613  else if (is_binary())
21614  {
21615  AllocatorType<binary_t> alloc;
21616  std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21617  std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21618  m_value.binary = nullptr;
21619  }
21620 
21621  m_type = value_t::null;
21622  assert_invariant();
21623  break;
21624  }
21625 
21626  case value_t::object:
21627  {
21628  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
21629  break;
21630  }
21631 
21632  case value_t::array:
21633  {
21634  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
21635  break;
21636  }
21637 
21638  case value_t::null:
21639  case value_t::discarded:
21640  default:
21641  JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
21642  }
21643 
21644  return result;
21645  }
21646 
21693  template < class IteratorType, typename std::enable_if <
21696  = 0 >
21697  IteratorType erase(IteratorType first, IteratorType last)
21698  {
21699  // make sure iterator fits the current value
21700  if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
21701  {
21702  JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", *this));
21703  }
21704 
21705  IteratorType result = end();
21706 
21707  switch (m_type)
21708  {
21709  case value_t::boolean:
21710  case value_t::number_float:
21713  case value_t::string:
21714  case value_t::binary:
21715  {
21716  if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
21717  || !last.m_it.primitive_iterator.is_end()))
21718  {
21719  JSON_THROW(invalid_iterator::create(204, "iterators out of range", *this));
21720  }
21721 
21722  if (is_string())
21723  {
21724  AllocatorType<string_t> alloc;
21725  std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21726  std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21727  m_value.string = nullptr;
21728  }
21729  else if (is_binary())
21730  {
21731  AllocatorType<binary_t> alloc;
21732  std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21733  std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21734  m_value.binary = nullptr;
21735  }
21736 
21737  m_type = value_t::null;
21738  assert_invariant();
21739  break;
21740  }
21741 
21742  case value_t::object:
21743  {
21744  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
21745  last.m_it.object_iterator);
21746  break;
21747  }
21748 
21749  case value_t::array:
21750  {
21751  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
21752  last.m_it.array_iterator);
21753  break;
21754  }
21755 
21756  case value_t::null:
21757  case value_t::discarded:
21758  default:
21759  JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
21760  }
21761 
21762  return result;
21763  }
21764 
21794  size_type erase(const typename object_t::key_type& key)
21795  {
21796  // this erase only works for objects
21798  {
21799  return m_value.object->erase(key);
21800  }
21801 
21802  JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
21803  }
21804 
21829  void erase(const size_type idx)
21830  {
21831  // this erase only works for arrays
21833  {
21834  if (JSON_HEDLEY_UNLIKELY(idx >= size()))
21835  {
21836  JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
21837  }
21838 
21839  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
21840  }
21841  else
21842  {
21843  JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
21844  }
21845  }
21846 
21848 
21849 
21851  // lookup //
21853 
21856 
21881  template<typename KeyT>
21882  iterator find(KeyT&& key)
21883  {
21884  auto result = end();
21885 
21886  if (is_object())
21887  {
21888  result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
21889  }
21890 
21891  return result;
21892  }
21893 
21898  template<typename KeyT>
21899  const_iterator find(KeyT&& key) const
21900  {
21901  auto result = cend();
21902 
21903  if (is_object())
21904  {
21905  result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
21906  }
21907 
21908  return result;
21909  }
21910 
21932  template<typename KeyT>
21933  size_type count(KeyT&& key) const
21934  {
21935  // return 0 for all nonobject types
21936  return is_object() ? m_value.object->count(std::forward<KeyT>(key)) : 0;
21937  }
21938 
21964  template < typename KeyT, typename std::enable_if <
21966  bool contains(KeyT && key) const
21967  {
21968  return is_object() && m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
21969  }
21970 
21997  bool contains(const json_pointer& ptr) const
21998  {
21999  return ptr.contains(this);
22000  }
22001 
22003 
22004 
22006  // iterators //
22008 
22011 
22036  iterator begin() noexcept
22037  {
22038  iterator result(this);
22039  result.set_begin();
22040  return result;
22041  }
22042 
22046  const_iterator begin() const noexcept
22047  {
22048  return cbegin();
22049  }
22050 
22076  const_iterator cbegin() const noexcept
22077  {
22078  const_iterator result(this);
22079  result.set_begin();
22080  return result;
22081  }
22082 
22107  iterator end() noexcept
22108  {
22109  iterator result(this);
22110  result.set_end();
22111  return result;
22112  }
22113 
22117  const_iterator end() const noexcept
22118  {
22119  return cend();
22120  }
22121 
22147  const_iterator cend() const noexcept
22148  {
22149  const_iterator result(this);
22150  result.set_end();
22151  return result;
22152  }
22153 
22178  {
22179  return reverse_iterator(end());
22180  }
22181 
22186  {
22187  return crbegin();
22188  }
22189 
22215  {
22216  return reverse_iterator(begin());
22217  }
22218 
22222  const_reverse_iterator rend() const noexcept
22223  {
22224  return crend();
22225  }
22226 
22252  {
22253  return const_reverse_iterator(cend());
22254  }
22255 
22281  {
22282  return const_reverse_iterator(cbegin());
22283  }
22284 
22285  public:
22345  {
22346  return ref.items();
22347  }
22348 
22354  {
22355  return ref.items();
22356  }
22357 
22427  {
22428  return iteration_proxy<iterator>(*this);
22429  }
22430 
22435  {
22436  return iteration_proxy<const_iterator>(*this);
22437  }
22438 
22440 
22441 
22443  // capacity //
22445 
22448 
22491  bool empty() const noexcept
22492  {
22493  switch (m_type)
22494  {
22495  case value_t::null:
22496  {
22497  // null values are empty
22498  return true;
22499  }
22500 
22501  case value_t::array:
22502  {
22503  // delegate call to array_t::empty()
22504  return m_value.array->empty();
22505  }
22506 
22507  case value_t::object:
22508  {
22509  // delegate call to object_t::empty()
22510  return m_value.object->empty();
22511  }
22512 
22513  case value_t::string:
22514  case value_t::boolean:
22517  case value_t::number_float:
22518  case value_t::binary:
22519  case value_t::discarded:
22520  default:
22521  {
22522  // all other types are nonempty
22523  return false;
22524  }
22525  }
22526  }
22527 
22571  size_type size() const noexcept
22572  {
22573  switch (m_type)
22574  {
22575  case value_t::null:
22576  {
22577  // null values are empty
22578  return 0;
22579  }
22580 
22581  case value_t::array:
22582  {
22583  // delegate call to array_t::size()
22584  return m_value.array->size();
22585  }
22586 
22587  case value_t::object:
22588  {
22589  // delegate call to object_t::size()
22590  return m_value.object->size();
22591  }
22592 
22593  case value_t::string:
22594  case value_t::boolean:
22597  case value_t::number_float:
22598  case value_t::binary:
22599  case value_t::discarded:
22600  default:
22601  {
22602  // all other types have size 1
22603  return 1;
22604  }
22605  }
22606  }
22607 
22649  size_type max_size() const noexcept
22650  {
22651  switch (m_type)
22652  {
22653  case value_t::array:
22654  {
22655  // delegate call to array_t::max_size()
22656  return m_value.array->max_size();
22657  }
22658 
22659  case value_t::object:
22660  {
22661  // delegate call to object_t::max_size()
22662  return m_value.object->max_size();
22663  }
22664 
22665  case value_t::null:
22666  case value_t::string:
22667  case value_t::boolean:
22670  case value_t::number_float:
22671  case value_t::binary:
22672  case value_t::discarded:
22673  default:
22674  {
22675  // all other types have max_size() == size()
22676  return size();
22677  }
22678  }
22679  }
22680 
22682 
22683 
22685  // modifiers //
22687 
22690 
22728  void clear() noexcept
22729  {
22730  switch (m_type)
22731  {
22733  {
22734  m_value.number_integer = 0;
22735  break;
22736  }
22737 
22739  {
22740  m_value.number_unsigned = 0;
22741  break;
22742  }
22743 
22744  case value_t::number_float:
22745  {
22746  m_value.number_float = 0.0;
22747  break;
22748  }
22749 
22750  case value_t::boolean:
22751  {
22752  m_value.boolean = false;
22753  break;
22754  }
22755 
22756  case value_t::string:
22757  {
22758  m_value.string->clear();
22759  break;
22760  }
22761 
22762  case value_t::binary:
22763  {
22764  m_value.binary->clear();
22765  break;
22766  }
22767 
22768  case value_t::array:
22769  {
22770  m_value.array->clear();
22771  break;
22772  }
22773 
22774  case value_t::object:
22775  {
22776  m_value.object->clear();
22777  break;
22778  }
22779 
22780  case value_t::null:
22781  case value_t::discarded:
22782  default:
22783  break;
22784  }
22785  }
22786 
22807  void push_back(basic_json&& val)
22808  {
22809  // push_back only works for null objects or arrays
22810  if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
22811  {
22812  JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
22813  }
22814 
22815  // transform null object into an array
22816  if (is_null())
22817  {
22818  m_type = value_t::array;
22820  assert_invariant();
22821  }
22822 
22823  // add element to array (move semantics)
22824  const auto old_capacity = m_value.array->capacity();
22825  m_value.array->push_back(std::move(val));
22826  set_parent(m_value.array->back(), old_capacity);
22827  // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
22828  }
22829 
22835  {
22836  push_back(std::move(val));
22837  return *this;
22838  }
22839 
22844  void push_back(const basic_json& val)
22845  {
22846  // push_back only works for null objects or arrays
22847  if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
22848  {
22849  JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
22850  }
22851 
22852  // transform null object into an array
22853  if (is_null())
22854  {
22855  m_type = value_t::array;
22857  assert_invariant();
22858  }
22859 
22860  // add element to array
22861  const auto old_capacity = m_value.array->capacity();
22862  m_value.array->push_back(val);
22863  set_parent(m_value.array->back(), old_capacity);
22864  }
22865 
22871  {
22872  push_back(val);
22873  return *this;
22874  }
22875 
22896  void push_back(const typename object_t::value_type& val)
22897  {
22898  // push_back only works for null objects or objects
22899  if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
22900  {
22901  JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
22902  }
22903 
22904  // transform null object into an object
22905  if (is_null())
22906  {
22907  m_type = value_t::object;
22909  assert_invariant();
22910  }
22911 
22912  // add element to object
22913  auto res = m_value.object->insert(val);
22914  set_parent(res.first->second);
22915  }
22916 
22921  reference operator+=(const typename object_t::value_type& val)
22922  {
22923  push_back(val);
22924  return *this;
22925  }
22926 
22953  {
22954  if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22955  {
22956  basic_json&& key = init.begin()->moved_or_copied();
22957  push_back(typename object_t::value_type(
22958  std::move(key.get_ref<string_t&>()), (init.begin() + 1)->moved_or_copied()));
22959  }
22960  else
22961  {
22963  }
22964  }
22965 
22971  {
22972  push_back(init);
22973  return *this;
22974  }
22975 
22999  template<class... Args>
23001  {
23002  // emplace_back only works for null objects or arrays
23003  if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
23004  {
23005  JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()), *this));
23006  }
23007 
23008  // transform null object into an array
23009  if (is_null())
23010  {
23011  m_type = value_t::array;
23013  assert_invariant();
23014  }
23015 
23016  // add element to array (perfect forwarding)
23017  const auto old_capacity = m_value.array->capacity();
23018  m_value.array->emplace_back(std::forward<Args>(args)...);
23019  return set_parent(m_value.array->back(), old_capacity);
23020  }
23021 
23049  template<class... Args>
23050  std::pair<iterator, bool> emplace(Args&& ... args)
23051  {
23052  // emplace only works for null objects or arrays
23053  if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
23054  {
23055  JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()), *this));
23056  }
23057 
23058  // transform null object into an object
23059  if (is_null())
23060  {
23061  m_type = value_t::object;
23063  assert_invariant();
23064  }
23065 
23066  // add element to array (perfect forwarding)
23067  auto res = m_value.object->emplace(std::forward<Args>(args)...);
23068  set_parent(res.first->second);
23069 
23070  // create result iterator and set iterator to the result of emplace
23071  auto it = begin();
23072  it.m_it.object_iterator = res.first;
23073 
23074  // return pair of iterator and boolean
23075  return {it, res.second};
23076  }
23077 
23081  template<typename... Args>
23083  {
23084  iterator result(this);
23085  JSON_ASSERT(m_value.array != nullptr);
23086 
23087  auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
23088  m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23089  result.m_it.array_iterator = m_value.array->begin() + insert_pos;
23090 
23091  // This could have been written as:
23092  // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
23093  // but the return value of insert is missing in GCC 4.8, so it is written this way instead.
23094 
23095  set_parents();
23096  return result;
23097  }
23098 
23122  {
23123  // insert only works for arrays
23125  {
23126  // check if iterator pos fits to this JSON value
23127  if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
23128  {
23129  JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
23130  }
23131 
23132  // insert to array and return iterator
23133  return insert_iterator(pos, val);
23134  }
23135 
23136  JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
23137  }
23138 
23144  {
23145  return insert(pos, val);
23146  }
23147 
23173  {
23174  // insert only works for arrays
23176  {
23177  // check if iterator pos fits to this JSON value
23178  if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
23179  {
23180  JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
23181  }
23182 
23183  // insert to array and return iterator
23184  return insert_iterator(pos, cnt, val);
23185  }
23186 
23187  JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
23188  }
23189 
23221  {
23222  // insert only works for arrays
23224  {
23225  JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
23226  }
23227 
23228  // check if iterator pos fits to this JSON value
23229  if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
23230  {
23231  JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
23232  }
23233 
23234  // check if range iterators belong to the same JSON object
23235  if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
23236  {
23237  JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
23238  }
23239 
23240  if (JSON_HEDLEY_UNLIKELY(first.m_object == this))
23241  {
23242  JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", *this));
23243  }
23244 
23245  // insert to array and return iterator
23246  return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23247  }
23248 
23274  {
23275  // insert only works for arrays
23277  {
23278  JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
23279  }
23280 
23281  // check if iterator pos fits to this JSON value
23282  if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
23283  {
23284  JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
23285  }
23286 
23287  // insert to array and return iterator
23288  return insert_iterator(pos, ilist.begin(), ilist.end());
23289  }
23290 
23315  {
23316  // insert only works for objects
23318  {
23319  JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
23320  }
23321 
23322  // check if range iterators belong to the same JSON object
23323  if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
23324  {
23325  JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
23326  }
23327 
23328  // passed iterators must belong to objects
23329  if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()))
23330  {
23331  JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this));
23332  }
23333 
23334  m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23335  }
23336 
23357  {
23358  // implicitly convert null value to an empty object
23359  if (is_null())
23360  {
23361  m_type = value_t::object;
23362  m_value.object = create<object_t>();
23363  assert_invariant();
23364  }
23365 
23367  {
23368  JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
23369  }
23370  if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
23371  {
23372  JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()), *this));
23373  }
23374 
23375  for (auto it = j.cbegin(); it != j.cend(); ++it)
23376  {
23377  m_value.object->operator[](it.key()) = it.value();
23378  }
23379  }
23380 
23408  {
23409  // implicitly convert null value to an empty object
23410  if (is_null())
23411  {
23412  m_type = value_t::object;
23413  m_value.object = create<object_t>();
23414  assert_invariant();
23415  }
23416 
23418  {
23419  JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
23420  }
23421 
23422  // check if range iterators belong to the same JSON object
23423  if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
23424  {
23425  JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
23426  }
23427 
23428  // passed iterators must belong to objects
23429  if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()
23430  || !last.m_object->is_object()))
23431  {
23432  JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this));
23433  }
23434 
23435  for (auto it = first; it != last; ++it)
23436  {
23437  m_value.object->operator[](it.key()) = it.value();
23438  }
23439  }
23440 
23458  void swap(reference other) noexcept (
23463  )
23464  {
23465  std::swap(m_type, other.m_type);
23466  std::swap(m_value, other.m_value);
23467 
23468  set_parents();
23469  other.set_parents();
23470  assert_invariant();
23471  }
23472 
23491  friend void swap(reference left, reference right) noexcept (
23496  )
23497  {
23498  left.swap(right);
23499  }
23500 
23521  void swap(array_t& other) // NOLINT(bugprone-exception-escape)
23522  {
23523  // swap only works for arrays
23525  {
23526  std::swap(*(m_value.array), other);
23527  }
23528  else
23529  {
23530  JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23531  }
23532  }
23533 
23554  void swap(object_t& other) // NOLINT(bugprone-exception-escape)
23555  {
23556  // swap only works for objects
23558  {
23559  std::swap(*(m_value.object), other);
23560  }
23561  else
23562  {
23563  JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23564  }
23565  }
23566 
23587  void swap(string_t& other) // NOLINT(bugprone-exception-escape)
23588  {
23589  // swap only works for strings
23591  {
23592  std::swap(*(m_value.string), other);
23593  }
23594  else
23595  {
23596  JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23597  }
23598  }
23599 
23620  void swap(binary_t& other) // NOLINT(bugprone-exception-escape)
23621  {
23622  // swap only works for strings
23624  {
23625  std::swap(*(m_value.binary), other);
23626  }
23627  else
23628  {
23629  JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23630  }
23631  }
23632 
23634  void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape)
23635  {
23636  // swap only works for strings
23638  {
23639  std::swap(*(m_value.binary), other);
23640  }
23641  else
23642  {
23643  JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23644  }
23645  }
23646 
23648 
23649  public:
23651  // lexicographical comparison operators //
23653 
23656 
23712  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
23713  {
23714 #ifdef __GNUC__
23715 #pragma GCC diagnostic push
23716 #pragma GCC diagnostic ignored "-Wfloat-equal"
23717 #endif
23718  const auto lhs_type = lhs.type();
23719  const auto rhs_type = rhs.type();
23720 
23721  if (lhs_type == rhs_type)
23722  {
23723  switch (lhs_type)
23724  {
23725  case value_t::array:
23726  return *lhs.m_value.array == *rhs.m_value.array;
23727 
23728  case value_t::object:
23729  return *lhs.m_value.object == *rhs.m_value.object;
23730 
23731  case value_t::null:
23732  return true;
23733 
23734  case value_t::string:
23735  return *lhs.m_value.string == *rhs.m_value.string;
23736 
23737  case value_t::boolean:
23738  return lhs.m_value.boolean == rhs.m_value.boolean;
23739 
23741  return lhs.m_value.number_integer == rhs.m_value.number_integer;
23742 
23744  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
23745 
23746  case value_t::number_float:
23747  return lhs.m_value.number_float == rhs.m_value.number_float;
23748 
23749  case value_t::binary:
23750  return *lhs.m_value.binary == *rhs.m_value.binary;
23751 
23752  case value_t::discarded:
23753  default:
23754  return false;
23755  }
23756  }
23757  else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
23758  {
23759  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
23760  }
23761  else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
23762  {
23763  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
23764  }
23765  else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
23766  {
23767  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
23768  }
23769  else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
23770  {
23771  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
23772  }
23773  else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
23774  {
23775  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
23776  }
23777  else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
23778  {
23779  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
23780  }
23781 
23782  return false;
23783 #ifdef __GNUC__
23784 #pragma GCC diagnostic pop
23785 #endif
23786  }
23787 
23792  template<typename ScalarType, typename std::enable_if<
23794  friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
23795  {
23796  return lhs == basic_json(rhs);
23797  }
23798 
23803  template<typename ScalarType, typename std::enable_if<
23805  friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
23806  {
23807  return basic_json(lhs) == rhs;
23808  }
23809 
23828  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
23829  {
23830  return !(lhs == rhs);
23831  }
23832 
23837  template<typename ScalarType, typename std::enable_if<
23839  friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
23840  {
23841  return lhs != basic_json(rhs);
23842  }
23843 
23848  template<typename ScalarType, typename std::enable_if<
23850  friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
23851  {
23852  return basic_json(lhs) != rhs;
23853  }
23854 
23881  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
23882  {
23883  const auto lhs_type = lhs.type();
23884  const auto rhs_type = rhs.type();
23885 
23886  if (lhs_type == rhs_type)
23887  {
23888  switch (lhs_type)
23889  {
23890  case value_t::array:
23891  // note parentheses are necessary, see
23892  // https://github.com/nlohmann/json/issues/1530
23893  return (*lhs.m_value.array) < (*rhs.m_value.array);
23894 
23895  case value_t::object:
23896  return (*lhs.m_value.object) < (*rhs.m_value.object);
23897 
23898  case value_t::null:
23899  return false;
23900 
23901  case value_t::string:
23902  return (*lhs.m_value.string) < (*rhs.m_value.string);
23903 
23904  case value_t::boolean:
23905  return (lhs.m_value.boolean) < (rhs.m_value.boolean);
23906 
23908  return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
23909 
23911  return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
23912 
23913  case value_t::number_float:
23914  return (lhs.m_value.number_float) < (rhs.m_value.number_float);
23915 
23916  case value_t::binary:
23917  return (*lhs.m_value.binary) < (*rhs.m_value.binary);
23918 
23919  case value_t::discarded:
23920  default:
23921  return false;
23922  }
23923  }
23924  else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
23925  {
23926  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
23927  }
23928  else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
23929  {
23930  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
23931  }
23932  else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
23933  {
23934  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
23935  }
23936  else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
23937  {
23938  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
23939  }
23940  else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
23941  {
23942  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
23943  }
23944  else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
23945  {
23946  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
23947  }
23948 
23949  // We only reach this line if we cannot compare values. In that case,
23950  // we compare types. Note we have to call the operator explicitly,
23951  // because MSVC has problems otherwise.
23952  return operator<(lhs_type, rhs_type);
23953  }
23954 
23959  template<typename ScalarType, typename std::enable_if<
23961  friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
23962  {
23963  return lhs < basic_json(rhs);
23964  }
23965 
23970  template<typename ScalarType, typename std::enable_if<
23972  friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
23973  {
23974  return basic_json(lhs) < rhs;
23975  }
23976 
23996  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
23997  {
23998  return !(rhs < lhs);
23999  }
24000 
24005  template<typename ScalarType, typename std::enable_if<
24007  friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
24008  {
24009  return lhs <= basic_json(rhs);
24010  }
24011 
24016  template<typename ScalarType, typename std::enable_if<
24018  friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
24019  {
24020  return basic_json(lhs) <= rhs;
24021  }
24022 
24042  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
24043  {
24044  return !(lhs <= rhs);
24045  }
24046 
24051  template<typename ScalarType, typename std::enable_if<
24053  friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
24054  {
24055  return lhs > basic_json(rhs);
24056  }
24057 
24062  template<typename ScalarType, typename std::enable_if<
24064  friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
24065  {
24066  return basic_json(lhs) > rhs;
24067  }
24068 
24088  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
24089  {
24090  return !(lhs < rhs);
24091  }
24092 
24097  template<typename ScalarType, typename std::enable_if<
24099  friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
24100  {
24101  return lhs >= basic_json(rhs);
24102  }
24103 
24108  template<typename ScalarType, typename std::enable_if<
24110  friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
24111  {
24112  return basic_json(lhs) >= rhs;
24113  }
24114 
24116 
24118  // serialization //
24120 
24123 #ifndef JSON_NO_IO
24124 
24155  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
24156  {
24157  // read width member and use it as indentation parameter if nonzero
24158  const bool pretty_print = o.width() > 0;
24159  const auto indentation = pretty_print ? o.width() : 0;
24160 
24161  // reset width to 0 for subsequent calls to this stream
24162  o.width(0);
24163 
24164  // do the actual serialization
24165  serializer s(detail::output_adapter<char>(o), o.fill());
24166  s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation));
24167  return o;
24168  }
24169 
24178  JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&))
24179  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
24180  {
24181  return o << j;
24182  }
24183 #endif // JSON_NO_IO
24184 
24186 
24188  // deserialization //
24190 
24193 
24245  template<typename InputType>
24247  static basic_json parse(InputType&& i,
24248  const parser_callback_t cb = nullptr,
24249  const bool allow_exceptions = true,
24250  const bool ignore_comments = false)
24251  {
24253  parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
24254  return result;
24255  }
24256 
24283  template<typename IteratorType>
24285  static basic_json parse(IteratorType first,
24286  IteratorType last,
24287  const parser_callback_t cb = nullptr,
24288  const bool allow_exceptions = true,
24289  const bool ignore_comments = false)
24290  {
24292  parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
24293  return result;
24294  }
24295 
24297  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
24298  static basic_json parse(detail::span_input_adapter&& i,
24299  const parser_callback_t cb = nullptr,
24300  const bool allow_exceptions = true,
24301  const bool ignore_comments = false)
24302  {
24304  parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result);
24305  return result;
24306  }
24307 
24338  template<typename InputType>
24339  static bool accept(InputType&& i,
24340  const bool ignore_comments = false)
24341  {
24342  return parser(detail::input_adapter(std::forward<InputType>(i)), nullptr, false, ignore_comments).accept(true);
24343  }
24344 
24345  template<typename IteratorType>
24346  static bool accept(IteratorType first, IteratorType last,
24347  const bool ignore_comments = false)
24348  {
24349  return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true);
24350  }
24351 
24353  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
24354  static bool accept(detail::span_input_adapter&& i,
24355  const bool ignore_comments = false)
24356  {
24357  return parser(i.get(), nullptr, false, ignore_comments).accept(true);
24358  }
24359 
24400  template <typename InputType, typename SAX>
24402  static bool sax_parse(InputType&& i, SAX* sax,
24404  const bool strict = true,
24405  const bool ignore_comments = false)
24406  {
24407  auto ia = detail::input_adapter(std::forward<InputType>(i));
24408  return format == input_format_t::json
24409  ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
24410  : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
24411  }
24412 
24413  template<class IteratorType, class SAX>
24415  static bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24417  const bool strict = true,
24418  const bool ignore_comments = false)
24419  {
24420  auto ia = detail::input_adapter(std::move(first), std::move(last));
24421  return format == input_format_t::json
24422  ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
24423  : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
24424  }
24425 
24426  template <typename SAX>
24427  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...))
24429  static bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
24431  const bool strict = true,
24432  const bool ignore_comments = false)
24433  {
24434  auto ia = i.get();
24435  return format == input_format_t::json
24436  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
24437  ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
24438  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
24439  : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
24440  }
24441 #ifndef JSON_NO_IO
24442 
24450  JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&))
24451  friend std::istream& operator<<(basic_json& j, std::istream& i)
24452  {
24453  return operator>>(i, j);
24454  }
24455 
24481  friend std::istream& operator>>(std::istream& i, basic_json& j)
24482  {
24483  parser(detail::input_adapter(i)).parse(false, j);
24484  return i;
24485  }
24486 #endif // JSON_NO_IO
24487 
24490  // convenience functions //
24492 
24525  const char* type_name() const noexcept
24526  {
24527  {
24528  switch (m_type)
24529  {
24530  case value_t::null:
24531  return "null";
24532  case value_t::object:
24533  return "object";
24534  case value_t::array:
24535  return "array";
24536  case value_t::string:
24537  return "string";
24538  case value_t::boolean:
24539  return "boolean";
24540  case value_t::binary:
24541  return "binary";
24542  case value_t::discarded:
24543  return "discarded";
24546  case value_t::number_float:
24547  default:
24548  return "number";
24549  }
24550  }
24551  }
24552 
24553 
24556  // member variables //
24558 
24561 
24564 
24565 #if JSON_DIAGNOSTICS
24566  basic_json* m_parent = nullptr;
24568 #endif
24569 
24571  // binary serialization/deserialization //
24573 
24576 
24577  public:
24676  static std::vector<std::uint8_t> to_cbor(const basic_json& j)
24677  {
24678  std::vector<std::uint8_t> result;
24679  to_cbor(j, result);
24680  return result;
24681  }
24682 
24684  {
24686  }
24687 
24689  {
24691  }
24692 
24771  static std::vector<std::uint8_t> to_msgpack(const basic_json& j)
24772  {
24773  std::vector<std::uint8_t> result;
24774  to_msgpack(j, result);
24775  return result;
24776  }
24777 
24779  {
24781  }
24782 
24784  {
24786  }
24787 
24874  static std::vector<std::uint8_t> to_ubjson(const basic_json& j,
24875  const bool use_size = false,
24876  const bool use_type = false)
24877  {
24878  std::vector<std::uint8_t> result;
24879  to_ubjson(j, result, use_size, use_type);
24880  return result;
24881  }
24882 
24884  const bool use_size = false, const bool use_type = false)
24885  {
24886  binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
24887  }
24888 
24890  const bool use_size = false, const bool use_type = false)
24891  {
24892  binary_writer<char>(o).write_ubjson(j, use_size, use_type);
24893  }
24894 
24895 
24952  static std::vector<std::uint8_t> to_bson(const basic_json& j)
24953  {
24954  std::vector<std::uint8_t> result;
24955  to_bson(j, result);
24956  return result;
24957  }
24958 
24968  {
24970  }
24971 
24976  {
24978  }
24979 
24980 
25083  template<typename InputType>
25085  static basic_json from_cbor(InputType&& i,
25086  const bool strict = true,
25087  const bool allow_exceptions = true,
25088  const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
25089  {
25091  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25092  auto ia = detail::input_adapter(std::forward<InputType>(i));
25093  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
25095  }
25096 
25100  template<typename IteratorType>
25102  static basic_json from_cbor(IteratorType first, IteratorType last,
25103  const bool strict = true,
25104  const bool allow_exceptions = true,
25105  const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
25106  {
25108  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25109  auto ia = detail::input_adapter(std::move(first), std::move(last));
25110  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
25112  }
25113 
25114  template<typename T>
25116  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
25117  static basic_json from_cbor(const T* ptr, std::size_t len,
25118  const bool strict = true,
25119  const bool allow_exceptions = true,
25120  const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
25121  {
25122  return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
25123  }
25124 
25125 
25127  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
25128  static basic_json from_cbor(detail::span_input_adapter&& i,
25129  const bool strict = true,
25130  const bool allow_exceptions = true,
25131  const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
25132  {
25134  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25135  auto ia = i.get();
25136  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
25137  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
25139  }
25140 
25227  template<typename InputType>
25229  static basic_json from_msgpack(InputType&& i,
25230  const bool strict = true,
25231  const bool allow_exceptions = true)
25232  {
25234  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25235  auto ia = detail::input_adapter(std::forward<InputType>(i));
25236  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
25238  }
25239 
25243  template<typename IteratorType>
25245  static basic_json from_msgpack(IteratorType first, IteratorType last,
25246  const bool strict = true,
25247  const bool allow_exceptions = true)
25248  {
25250  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25251  auto ia = detail::input_adapter(std::move(first), std::move(last));
25252  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
25254  }
25255 
25256 
25257  template<typename T>
25259  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
25260  static basic_json from_msgpack(const T* ptr, std::size_t len,
25261  const bool strict = true,
25262  const bool allow_exceptions = true)
25263  {
25264  return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
25265  }
25266 
25268  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
25269  static basic_json from_msgpack(detail::span_input_adapter&& i,
25270  const bool strict = true,
25271  const bool allow_exceptions = true)
25272  {
25274  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25275  auto ia = i.get();
25276  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
25277  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
25279  }
25280 
25281 
25344  template<typename InputType>
25346  static basic_json from_ubjson(InputType&& i,
25347  const bool strict = true,
25348  const bool allow_exceptions = true)
25349  {
25351  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25352  auto ia = detail::input_adapter(std::forward<InputType>(i));
25353  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
25355  }
25356 
25360  template<typename IteratorType>
25362  static basic_json from_ubjson(IteratorType first, IteratorType last,
25363  const bool strict = true,
25364  const bool allow_exceptions = true)
25365  {
25367  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25368  auto ia = detail::input_adapter(std::move(first), std::move(last));
25369  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
25371  }
25372 
25373  template<typename T>
25375  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
25376  static basic_json from_ubjson(const T* ptr, std::size_t len,
25377  const bool strict = true,
25378  const bool allow_exceptions = true)
25379  {
25380  return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
25381  }
25382 
25384  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
25385  static basic_json from_ubjson(detail::span_input_adapter&& i,
25386  const bool strict = true,
25387  const bool allow_exceptions = true)
25388  {
25390  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25391  auto ia = i.get();
25392  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
25393  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
25395  }
25396 
25397 
25458  template<typename InputType>
25460  static basic_json from_bson(InputType&& i,
25461  const bool strict = true,
25462  const bool allow_exceptions = true)
25463  {
25465  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25466  auto ia = detail::input_adapter(std::forward<InputType>(i));
25467  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
25469  }
25470 
25474  template<typename IteratorType>
25476  static basic_json from_bson(IteratorType first, IteratorType last,
25477  const bool strict = true,
25478  const bool allow_exceptions = true)
25479  {
25481  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25482  auto ia = detail::input_adapter(std::move(first), std::move(last));
25483  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
25485  }
25486 
25487  template<typename T>
25489  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
25490  static basic_json from_bson(const T* ptr, std::size_t len,
25491  const bool strict = true,
25492  const bool allow_exceptions = true)
25493  {
25494  return from_bson(ptr, ptr + len, strict, allow_exceptions);
25495  }
25496 
25498  JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
25499  static basic_json from_bson(detail::span_input_adapter&& i,
25500  const bool strict = true,
25501  const bool allow_exceptions = true)
25502  {
25504  detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
25505  auto ia = i.get();
25506  // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
25507  const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
25509  }
25511 
25513  // JSON Pointer support //
25515 
25518 
25553  {
25554  return ptr.get_unchecked(this);
25555  }
25556 
25581  {
25582  return ptr.get_unchecked(this);
25583  }
25584 
25624  {
25625  return ptr.get_checked(this);
25626  }
25627 
25666  const_reference at(const json_pointer& ptr) const
25667  {
25668  return ptr.get_checked(this);
25669  }
25670 
25694  {
25696  json_pointer::flatten("", *this, result);
25697  return result;
25698  }
25699 
25731  {
25732  return json_pointer::unflatten(*this);
25733  }
25734 
25736 
25738  // JSON Patch functions //
25740 
25743 
25791  basic_json patch(const basic_json& json_patch) const
25792  {
25793  // make a working copy to apply the patch to
25794  basic_json result = *this;
25795 
25796  // the valid JSON Patch operations
25797  enum class patch_operations {add, remove, replace, move, copy, test, invalid};
25798 
25799  const auto get_op = [](const std::string & op)
25800  {
25801  if (op == "add")
25802  {
25803  return patch_operations::add;
25804  }
25805  if (op == "remove")
25806  {
25807  return patch_operations::remove;
25808  }
25809  if (op == "replace")
25810  {
25812  }
25813  if (op == "move")
25814  {
25815  return patch_operations::move;
25816  }
25817  if (op == "copy")
25818  {
25819  return patch_operations::copy;
25820  }
25821  if (op == "test")
25822  {
25823  return patch_operations::test;
25824  }
25825 
25826  return patch_operations::invalid;
25827  };
25828 
25829  // wrapper for "add" operation; add value at ptr
25830  const auto operation_add = [&result](json_pointer & ptr, basic_json val)
25831  {
25832  // adding to the root of the target document means replacing it
25833  if (ptr.empty())
25834  {
25835  result = val;
25836  return;
25837  }
25838 
25839  // make sure the top element of the pointer exists
25840  json_pointer top_pointer = ptr.top();
25841  if (top_pointer != ptr)
25842  {
25843  result.at(top_pointer);
25844  }
25845 
25846  // get reference to parent of JSON pointer ptr
25847  const auto last_path = ptr.back();
25848  ptr.pop_back();
25849  basic_json& parent = result[ptr];
25850 
25851  switch (parent.m_type)
25852  {
25853  case value_t::null:
25854  case value_t::object:
25855  {
25856  // use operator[] to add value
25857  parent[last_path] = val;
25858  break;
25859  }
25860 
25861  case value_t::array:
25862  {
25863  if (last_path == "-")
25864  {
25865  // special case: append to back
25866  parent.push_back(val);
25867  }
25868  else
25869  {
25870  const auto idx = json_pointer::array_index(last_path);
25871  if (JSON_HEDLEY_UNLIKELY(idx > parent.size()))
25872  {
25873  // avoid undefined behavior
25874  JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", parent));
25875  }
25876 
25877  // default case: insert add offset
25878  parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
25879  }
25880  break;
25881  }
25882 
25883  // if there exists a parent it cannot be primitive
25884  case value_t::string: // LCOV_EXCL_LINE
25885  case value_t::boolean: // LCOV_EXCL_LINE
25886  case value_t::number_integer: // LCOV_EXCL_LINE
25887  case value_t::number_unsigned: // LCOV_EXCL_LINE
25888  case value_t::number_float: // LCOV_EXCL_LINE
25889  case value_t::binary: // LCOV_EXCL_LINE
25890  case value_t::discarded: // LCOV_EXCL_LINE
25891  default: // LCOV_EXCL_LINE
25892  JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
25893  }
25894  };
25895 
25896  // wrapper for "remove" operation; remove value at ptr
25897  const auto operation_remove = [this, &result](json_pointer & ptr)
25898  {
25899  // get reference to parent of JSON pointer ptr
25900  const auto last_path = ptr.back();
25901  ptr.pop_back();
25902  basic_json& parent = result.at(ptr);
25903 
25904  // remove child
25905  if (parent.is_object())
25906  {
25907  // perform range check
25908  auto it = parent.find(last_path);
25909  if (JSON_HEDLEY_LIKELY(it != parent.end()))
25910  {
25911  parent.erase(it);
25912  }
25913  else
25914  {
25915  JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found", *this));
25916  }
25917  }
25918  else if (parent.is_array())
25919  {
25920  // note erase performs range check
25921  parent.erase(json_pointer::array_index(last_path));
25922  }
25923  };
25924 
25925  // type check: top level value must be an array
25926  if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array()))
25927  {
25928  JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", json_patch));
25929  }
25930 
25931  // iterate and apply the operations
25932  for (const auto& val : json_patch)
25933  {
25934  // wrapper to get a value for an operation
25935  const auto get_value = [&val](const std::string & op,
25936  const std::string & member,
25937  bool string_type) -> basic_json &
25938  {
25939  // find value
25940  auto it = val.m_value.object->find(member);
25941 
25942  // context-sensitive error message
25943  const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
25944 
25945  // check if desired value is present
25946  if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end()))
25947  {
25948  // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
25949  JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'", val));
25950  }
25951 
25952  // check if result is of type string
25953  if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
25954  {
25955  // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
25956  JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'", val));
25957  }
25958 
25959  // no error: return value
25960  return it->second;
25961  };
25962 
25963  // type check: every element of the array must be an object
25964  if (JSON_HEDLEY_UNLIKELY(!val.is_object()))
25965  {
25966  JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", val));
25967  }
25968 
25969  // collect mandatory members
25970  const auto op = get_value("op", "op", true).template get<std::string>();
25971  const auto path = get_value(op, "path", true).template get<std::string>();
25972  json_pointer ptr(path);
25973 
25974  switch (get_op(op))
25975  {
25976  case patch_operations::add:
25977  {
25978  operation_add(ptr, get_value("add", "value", false));
25979  break;
25980  }
25981 
25982  case patch_operations::remove:
25983  {
25984  operation_remove(ptr);
25985  break;
25986  }
25987 
25989  {
25990  // the "path" location must exist - use at()
25991  result.at(ptr) = get_value("replace", "value", false);
25992  break;
25993  }
25994 
25995  case patch_operations::move:
25996  {
25997  const auto from_path = get_value("move", "from", true).template get<std::string>();
25998  json_pointer from_ptr(from_path);
25999 
26000  // the "from" location must exist - use at()
26001  basic_json v = result.at(from_ptr);
26002 
26003  // The move operation is functionally identical to a
26004  // "remove" operation on the "from" location, followed
26005  // immediately by an "add" operation at the target
26006  // location with the value that was just removed.
26007  operation_remove(from_ptr);
26008  operation_add(ptr, v);
26009  break;
26010  }
26011 
26012  case patch_operations::copy:
26013  {
26014  const auto from_path = get_value("copy", "from", true).template get<std::string>();
26015  const json_pointer from_ptr(from_path);
26016 
26017  // the "from" location must exist - use at()
26018  basic_json v = result.at(from_ptr);
26019 
26020  // The copy is functionally identical to an "add"
26021  // operation at the target location using the value
26022  // specified in the "from" member.
26023  operation_add(ptr, v);
26024  break;
26025  }
26026 
26027  case patch_operations::test:
26028  {
26029  bool success = false;
26030  JSON_TRY
26031  {
26032  // check if "value" matches the one at "path"
26033  // the "path" location must exist - use at()
26034  success = (result.at(ptr) == get_value("test", "value", false));
26035  }
26037  {
26038  // ignore out of range errors: success remains false
26039  }
26040 
26041  // throw an exception if test fails
26042  if (JSON_HEDLEY_UNLIKELY(!success))
26043  {
26044  JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump(), val));
26045  }
26046 
26047  break;
26048  }
26049 
26050  case patch_operations::invalid:
26051  default:
26052  {
26053  // op must be "add", "remove", "replace", "move", "copy", or
26054  // "test"
26055  JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid", val));
26056  }
26057  }
26058  }
26059 
26060  return result;
26061  }
26062 
26097  static basic_json diff(const basic_json& source, const basic_json& target,
26098  const std::string& path = "")
26099  {
26100  // the patch
26102 
26103  // if the values are the same, return empty patch
26104  if (source == target)
26105  {
26106  return result;
26107  }
26108 
26109  if (source.type() != target.type())
26110  {
26111  // different types: replace value
26112  result.push_back(
26113  {
26114  {"op", "replace"}, {"path", path}, {"value", target}
26115  });
26116  return result;
26117  }
26118 
26119  switch (source.type())
26120  {
26121  case value_t::array:
26122  {
26123  // first pass: traverse common elements
26124  std::size_t i = 0;
26125  while (i < source.size() && i < target.size())
26126  {
26127  // recursive call to compare array values at index i
26128  auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
26129  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
26130  ++i;
26131  }
26132 
26133  // i now reached the end of at least one array
26134  // in a second pass, traverse the remaining elements
26135 
26136  // remove my remaining elements
26137  const auto end_index = static_cast<difference_type>(result.size());
26138  while (i < source.size())
26139  {
26140  // add operations in reverse order to avoid invalid
26141  // indices
26142  result.insert(result.begin() + end_index, object(
26143  {
26144  {"op", "remove"},
26145  {"path", path + "/" + std::to_string(i)}
26146  }));
26147  ++i;
26148  }
26149 
26150  // add other remaining elements
26151  while (i < target.size())
26152  {
26153  result.push_back(
26154  {
26155  {"op", "add"},
26156  {"path", path + "/-"},
26157  {"value", target[i]}
26158  });
26159  ++i;
26160  }
26161 
26162  break;
26163  }
26164 
26165  case value_t::object:
26166  {
26167  // first pass: traverse this object's elements
26168  for (auto it = source.cbegin(); it != source.cend(); ++it)
26169  {
26170  // escape the key name to be used in a JSON patch
26171  const auto path_key = path + "/" + detail::escape(it.key());
26172 
26173  if (target.find(it.key()) != target.end())
26174  {
26175  // recursive call to compare object values at key it
26176  auto temp_diff = diff(it.value(), target[it.key()], path_key);
26177  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
26178  }
26179  else
26180  {
26181  // found a key that is not in o -> remove it
26182  result.push_back(object(
26183  {
26184  {"op", "remove"}, {"path", path_key}
26185  }));
26186  }
26187  }
26188 
26189  // second pass: traverse other object's elements
26190  for (auto it = target.cbegin(); it != target.cend(); ++it)
26191  {
26192  if (source.find(it.key()) == source.end())
26193  {
26194  // found a key that is not in this -> add it
26195  const auto path_key = path + "/" + detail::escape(it.key());
26196  result.push_back(
26197  {
26198  {"op", "add"}, {"path", path_key},
26199  {"value", it.value()}
26200  });
26201  }
26202  }
26203 
26204  break;
26205  }
26206 
26207  case value_t::null:
26208  case value_t::string:
26209  case value_t::boolean:
26212  case value_t::number_float:
26213  case value_t::binary:
26214  case value_t::discarded:
26215  default:
26216  {
26217  // both primitive type: replace value
26218  result.push_back(
26219  {
26220  {"op", "replace"}, {"path", path}, {"value", target}
26221  });
26222  break;
26223  }
26224  }
26225 
26226  return result;
26227  }
26228 
26230 
26232  // JSON Merge Patch functions //
26234 
26237 
26280  void merge_patch(const basic_json& apply_patch)
26281  {
26282  if (apply_patch.is_object())
26283  {
26284  if (!is_object())
26285  {
26286  *this = object();
26287  }
26288  for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
26289  {
26290  if (it.value().is_null())
26291  {
26292  erase(it.key());
26293  }
26294  else
26295  {
26296  operator[](it.key()).merge_patch(it.value());
26297  }
26298  }
26299  }
26300  else
26301  {
26302  *this = apply_patch;
26303  }
26304  }
26305 
26307 };
26308 
26319 std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j)
26320 {
26321  return j.dump();
26322 }
26323 } // namespace nlohmann
26324 
26326 // nonmember support //
26328 
26329 // specialization of std::swap, and std::hash
26330 namespace std
26331 {
26332 
26334 template<>
26336 {
26342  std::size_t operator()(const nlohmann::json& j) const
26343  {
26344  return nlohmann::detail::hash(j);
26345  }
26346 };
26347 
26351 template<>
26353 {
26359  nlohmann::detail::value_t rhs) const noexcept
26360  {
26361  return nlohmann::detail::operator<(lhs, rhs);
26362  }
26363 };
26364 
26365 // C++20 prohibit function specialization in the std namespace.
26366 #ifndef JSON_HAS_CPP_20
26367 
26373 template<>
26374 inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name)
26375  is_nothrow_move_constructible<nlohmann::json>::value&& // NOLINT(misc-redundant-expression)
26377  )
26378 {
26379  j1.swap(j2);
26380 }
26381 
26382 #endif
26383 
26384 } // namespace std
26385 
26400 inline nlohmann::json operator "" _json(const char* s, std::size_t n)
26401 {
26402  return nlohmann::json::parse(s, s + n);
26403 }
26404 
26419 inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
26420 {
26421  return nlohmann::json::json_pointer(std::string(s, n));
26422 }
26423 
26424 // #include <nlohmann/detail/macro_unscope.hpp>
26425 
26426 
26427 // restore clang diagnostic settings
26428 #if defined(__clang__)
26429  #pragma clang diagnostic pop
26430 #endif
26431 
26432 // clean up
26433 #undef JSON_ASSERT
26434 #undef JSON_INTERNAL_CATCH
26435 #undef JSON_CATCH
26436 #undef JSON_THROW
26437 #undef JSON_TRY
26438 #undef JSON_PRIVATE_UNLESS_TESTED
26439 #undef JSON_HAS_CPP_11
26440 #undef JSON_HAS_CPP_14
26441 #undef JSON_HAS_CPP_17
26442 #undef JSON_HAS_CPP_20
26443 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
26444 #undef NLOHMANN_BASIC_JSON_TPL
26445 #undef JSON_EXPLICIT
26446 
26447 // #include <nlohmann/thirdparty/hedley/hedley_undef.hpp>
26448 
26449 
26450 #undef JSON_HEDLEY_ALWAYS_INLINE
26451 #undef JSON_HEDLEY_ARM_VERSION
26452 #undef JSON_HEDLEY_ARM_VERSION_CHECK
26453 #undef JSON_HEDLEY_ARRAY_PARAM
26454 #undef JSON_HEDLEY_ASSUME
26455 #undef JSON_HEDLEY_BEGIN_C_DECLS
26456 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
26457 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
26458 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
26459 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
26460 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
26461 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
26462 #undef JSON_HEDLEY_CLANG_HAS_WARNING
26463 #undef JSON_HEDLEY_COMPCERT_VERSION
26464 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
26465 #undef JSON_HEDLEY_CONCAT
26466 #undef JSON_HEDLEY_CONCAT3
26467 #undef JSON_HEDLEY_CONCAT3_EX
26468 #undef JSON_HEDLEY_CONCAT_EX
26469 #undef JSON_HEDLEY_CONST
26470 #undef JSON_HEDLEY_CONSTEXPR
26471 #undef JSON_HEDLEY_CONST_CAST
26472 #undef JSON_HEDLEY_CPP_CAST
26473 #undef JSON_HEDLEY_CRAY_VERSION
26474 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
26475 #undef JSON_HEDLEY_C_DECL
26476 #undef JSON_HEDLEY_DEPRECATED
26477 #undef JSON_HEDLEY_DEPRECATED_FOR
26478 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
26479 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
26480 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
26481 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
26482 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
26483 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
26484 #undef JSON_HEDLEY_DIAGNOSTIC_POP
26485 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
26486 #undef JSON_HEDLEY_DMC_VERSION
26487 #undef JSON_HEDLEY_DMC_VERSION_CHECK
26488 #undef JSON_HEDLEY_EMPTY_BASES
26489 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
26490 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
26491 #undef JSON_HEDLEY_END_C_DECLS
26492 #undef JSON_HEDLEY_FLAGS
26493 #undef JSON_HEDLEY_FLAGS_CAST
26494 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
26495 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
26496 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
26497 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
26498 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
26499 #undef JSON_HEDLEY_GCC_HAS_FEATURE
26500 #undef JSON_HEDLEY_GCC_HAS_WARNING
26501 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
26502 #undef JSON_HEDLEY_GCC_VERSION
26503 #undef JSON_HEDLEY_GCC_VERSION_CHECK
26504 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
26505 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
26506 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
26507 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
26508 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
26509 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
26510 #undef JSON_HEDLEY_GNUC_HAS_WARNING
26511 #undef JSON_HEDLEY_GNUC_VERSION
26512 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
26513 #undef JSON_HEDLEY_HAS_ATTRIBUTE
26514 #undef JSON_HEDLEY_HAS_BUILTIN
26515 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
26516 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
26517 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
26518 #undef JSON_HEDLEY_HAS_EXTENSION
26519 #undef JSON_HEDLEY_HAS_FEATURE
26520 #undef JSON_HEDLEY_HAS_WARNING
26521 #undef JSON_HEDLEY_IAR_VERSION
26522 #undef JSON_HEDLEY_IAR_VERSION_CHECK
26523 #undef JSON_HEDLEY_IBM_VERSION
26524 #undef JSON_HEDLEY_IBM_VERSION_CHECK
26525 #undef JSON_HEDLEY_IMPORT
26526 #undef JSON_HEDLEY_INLINE
26527 #undef JSON_HEDLEY_INTEL_CL_VERSION
26528 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
26529 #undef JSON_HEDLEY_INTEL_VERSION
26530 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
26531 #undef JSON_HEDLEY_IS_CONSTANT
26532 #undef JSON_HEDLEY_IS_CONSTEXPR_
26533 #undef JSON_HEDLEY_LIKELY
26534 #undef JSON_HEDLEY_MALLOC
26535 #undef JSON_HEDLEY_MCST_LCC_VERSION
26536 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
26537 #undef JSON_HEDLEY_MESSAGE
26538 #undef JSON_HEDLEY_MSVC_VERSION
26539 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
26540 #undef JSON_HEDLEY_NEVER_INLINE
26541 #undef JSON_HEDLEY_NON_NULL
26542 #undef JSON_HEDLEY_NO_ESCAPE
26543 #undef JSON_HEDLEY_NO_RETURN
26544 #undef JSON_HEDLEY_NO_THROW
26545 #undef JSON_HEDLEY_NULL
26546 #undef JSON_HEDLEY_PELLES_VERSION
26547 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
26548 #undef JSON_HEDLEY_PGI_VERSION
26549 #undef JSON_HEDLEY_PGI_VERSION_CHECK
26550 #undef JSON_HEDLEY_PREDICT
26551 #undef JSON_HEDLEY_PRINTF_FORMAT
26552 #undef JSON_HEDLEY_PRIVATE
26553 #undef JSON_HEDLEY_PUBLIC
26554 #undef JSON_HEDLEY_PURE
26555 #undef JSON_HEDLEY_REINTERPRET_CAST
26556 #undef JSON_HEDLEY_REQUIRE
26557 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
26558 #undef JSON_HEDLEY_REQUIRE_MSG
26559 #undef JSON_HEDLEY_RESTRICT
26560 #undef JSON_HEDLEY_RETURNS_NON_NULL
26561 #undef JSON_HEDLEY_SENTINEL
26562 #undef JSON_HEDLEY_STATIC_ASSERT
26563 #undef JSON_HEDLEY_STATIC_CAST
26564 #undef JSON_HEDLEY_STRINGIFY
26565 #undef JSON_HEDLEY_STRINGIFY_EX
26566 #undef JSON_HEDLEY_SUNPRO_VERSION
26567 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
26568 #undef JSON_HEDLEY_TINYC_VERSION
26569 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
26570 #undef JSON_HEDLEY_TI_ARMCL_VERSION
26571 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
26572 #undef JSON_HEDLEY_TI_CL2000_VERSION
26573 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
26574 #undef JSON_HEDLEY_TI_CL430_VERSION
26575 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
26576 #undef JSON_HEDLEY_TI_CL6X_VERSION
26577 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
26578 #undef JSON_HEDLEY_TI_CL7X_VERSION
26579 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
26580 #undef JSON_HEDLEY_TI_CLPRU_VERSION
26581 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
26582 #undef JSON_HEDLEY_TI_VERSION
26583 #undef JSON_HEDLEY_TI_VERSION_CHECK
26584 #undef JSON_HEDLEY_UNAVAILABLE
26585 #undef JSON_HEDLEY_UNLIKELY
26586 #undef JSON_HEDLEY_UNPREDICTABLE
26587 #undef JSON_HEDLEY_UNREACHABLE
26588 #undef JSON_HEDLEY_UNREACHABLE_RETURN
26589 #undef JSON_HEDLEY_VERSION
26590 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
26591 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
26592 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
26593 #undef JSON_HEDLEY_VERSION_ENCODE
26594 #undef JSON_HEDLEY_WARNING
26595 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
26596 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
26597 #undef JSON_HEDLEY_FALL_THROUGH
26598 
26599 
26600 
26601 #endif // INCLUDE_NLOHMANN_JSON_HPP_
nlohmann::detail::lexer::get_token_string
std::string get_token_string() const
Definition: json.hpp:7950
nlohmann::detail::json_reverse_iterator
a template for a reverse iterator class
Definition: json.hpp:12244
nlohmann::basic_json::find
const_iterator find(KeyT &&key) const
find an element in a JSON object
Definition: json.hpp:21899
nlohmann::detail::iter_impl::operator-
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:12111
nlohmann::detail::int_to_string
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:4344
nlohmann::detail::iteration_proxy::begin
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:4460
nlohmann::detail::primitive_iterator_t::operator+=
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:11422
nlohmann::basic_json::unflatten
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition: json.hpp:25730
nlohmann::basic_json::flatten
basic_json flatten() const
return flattened JSON value
Definition: json.hpp:25693
give.next
def next
Definition: give.py:44
nlohmann::detail::binary_writer::write_number
void write_number(const NumberType n)
Definition: json.hpp:15091
nlohmann::detail::json_sax_dom_callback_parser::parse_event_t
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6131
nlohmann::detail::serializer::UTF8_ACCEPT
static constexpr std::uint8_t UTF8_ACCEPT
Definition: json.hpp:16352
nlohmann::detail::type_error::create
static type_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2927
nlohmann::detail::lexer::get_number_float
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:7926
nlohmann::basic_json::operator<=
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
Definition: json.hpp:24007
nlohmann::detail::type_error
exception indicating executing a member function with a wrong type
Definition: json.hpp:2923
nlohmann::ordered_map::at
T & at(const Key &key)
Definition: json.hpp:17330
nlohmann::basic_json::back
const_reference back() const
access the last element
Definition: json.hpp:21525
nlohmann::detail::primitive_iterator_t::operator++
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:11396
nlohmann::basic_json::operator>
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:24064
nlohmann::detail::difference_type_t
typename T::difference_type difference_type_t
Definition: json.hpp:3480
nlohmann::basic_json::get_impl_ptr
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20285
nlohmann::basic_json::parser_callback_t
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:18799
nlohmann::detail::exception::what
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:2649
nlohmann::detail::dtoa_impl::diyfp::kPrecision
static constexpr int kPrecision
Definition: json.hpp:15254
object
Definition: object.h:282
nlohmann::detail::iteration_proxy_value::difference_type
std::ptrdiff_t difference_type
Definition: json.hpp:4353
NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2339
nlohmann::basic_json::json_value
json_value()=default
default constructor (for null values)
nlohmann::detail::binary_writer::write_cbor
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:13626
nlohmann::detail::json_ref::json_ref
json_ref(value_type &&value)
Definition: json.hpp:13347
nlohmann::detail::file_input_adapter::get_character
std::char_traits< char >::int_type get_character() noexcept
Definition: json.hpp:5361
nlohmann::detail::lexer::reset
void reset() noexcept
reset token_buffer; current character is beginning of token
Definition: json.hpp:7822
nlohmann::basic_json::is_string
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:20120
nlohmann::detail::iterator_types< It, void_t< typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category > >::iterator_category
typename It::iterator_category iterator_category
Definition: json.hpp:3246
nlohmann::basic_json::get_allocator
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:17703
JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:955
nlohmann::detail::binary_reader::is_little_endian
const bool is_little_endian
whether we can assume little endianess
Definition: json.hpp:10788
nlohmann::detail::dtoa_impl::compute_boundaries
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:15384
nlohmann::basic_json::operator<
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:23972
nlohmann::detail::wide_string_input_adapter::wide_string_input_adapter
wide_string_input_adapter(BaseInputAdapter base)
Definition: json.hpp:5601
nlohmann::basic_json::set_parents
void set_parents()
Definition: json.hpp:18655
nlohmann::detail::binary_writer::write_bson_unsigned
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
Definition: json.hpp:14598
nlohmann::detail::iter_impl::operator->
pointer operator->() const
dereference the iterator
Definition: json.hpp:11780
nlohmann::detail::start_array_function_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:8193
nlohmann::detail::binary_reader::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8331
castle_read.prefix
string prefix
Definition: castle_read.py:31
nlohmann::detail::other_error::create
static other_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:3014
nlohmann::detail::hash
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5197
nlohmann::detail::json_sax_dom_callback_parser::string
bool string(string_t &val)
Definition: json.hpp:6178
nlohmann::byte_container_with_subtype::byte_container_with_subtype
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5026
nlohmann::detail::is_iterator_of_multibyte
Definition: json.hpp:5654
nlohmann::detail::utility_internal::Gen::type
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:3128
nlohmann::detail::binary_writer::to_char_type
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:15170
nlohmann::detail::lexer::get_position
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:7942
nlohmann::detail::is_compatible_object_type_impl< BasicJsonType, CompatibleObjectType, enable_if_t< is_detected< mapped_type_t, CompatibleObjectType >::value &&is_detected< key_type_t, CompatibleObjectType >::value > >::object_t
typename BasicJsonType::object_t object_t
Definition: json.hpp:3649
nlohmann::detail::iteration_proxy_value::value
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:4441
banquet.l
l
Definition: banquet.py:164
nlohmann::detail::get_arithmetic_value
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:3886
nlohmann::basic_json::to_msgpack
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:24771
nlohmann::to_string
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:26319
nlohmann::detail::binary_reader::get_token_string
std::string get_token_string() const
Definition: json.hpp:10732
nlohmann::detail::binary_reader::get_cbor_string
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:9165
nlohmann::basic_json::operator+=
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22921
nlohmann::detail::json_sax_dom_parser::string
bool string(string_t &val)
Definition: json.hpp:6003
nlohmann::basic_json::get_impl
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
Definition: json.hpp:20477
nlohmann::basic_json::from_ubjson
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
Definition: json.hpp:25362
nlohmann::detail::json_ref::moved_or_copied
value_type moved_or_copied() const
Definition: json.hpp:13373
nlohmann::detail::lexer::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6616
nlohmann::basic_json::assert_invariant
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:18634
nlohmann::detail::exception
general exception of the basic_json class
Definition: json.hpp:2645
nlohmann::detail::utility_internal::Gen
Definition: json.hpp:3125
nlohmann::detail::parse_error::parse_error
parse_error(int id_, std::size_t byte_, const char *what_arg)
Definition: json.hpp:2821
nlohmann::detail::is_sax_static_asserts
Definition: json.hpp:8235
nlohmann::detail::binary_writer::calc_bson_array_size
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition: json.hpp:14630
nlohmann::detail::input_adapter
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5679
nlohmann::json_pointer::get_unchecked
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition: json.hpp:12815
nlohmann::basic_json::basic_json
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:18840
nlohmann::detail::output_vector_adapter::v
std::vector< CharType > & v
Definition: json.hpp:13484
nlohmann::basic_json::boolean
boolean_t boolean
boolean
Definition: json.hpp:18366
nlohmann::json_pointer::empty
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:12655
nlohmann::basic_json::basic_json
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:18864
nlohmann::basic_json::basic_json
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
Definition: json.hpp:19098
nlohmann::detail::has_from_json
Definition: json.hpp:3505
nlohmann::detail::has_to_json< BasicJsonType, T, enable_if_t< !is_basic_json< T >::value > >::serializer
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3550
nlohmann::detail::value_t
value_t
the JSON type enumeration
Definition: json.hpp:120
nlohmann::detail::serializer::state
std::uint8_t state
Definition: json.hpp:16688
nlohmann::detail::cbor_tag_handler_t::ignore
@ ignore
ignore tags
nlohmann::detail::wide_string_input_helper< BaseInputAdapter, 4 >::fill_buffer
static void fill_buffer(BaseInputAdapter &input, std::array< std::char_traits< char >::int_type, 4 > &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
Definition: json.hpp:5478
nlohmann::detail::json_ref::owned_value
value_type owned_value
Definition: json.hpp:13393
nlohmann::basic_json::rbegin
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:22185
nlohmann::detail::serializer::indent_string
string_t indent_string
the indentation string
Definition: json.hpp:17254
nlohmann::basic_json::value_t
detail::value_t value_t
Definition: json.hpp:17618
nlohmann::detail::iter_impl::iter_impl
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:11631
nlohmann::detail::iter_impl::operator--
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:11884
nlohmann::basic_json::binary
binary_t * binary
binary (stored with pointer to save storage)
Definition: json.hpp:18364
std::tuple_element< N, ::nlohmann::detail::iteration_proxy_value< IteratorType > >::type
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:4511
nlohmann::detail::start_object_function_t
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8182
nlohmann::detail::json_sax_dom_parser::handle_value
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
Definition: json.hpp:6087
nlohmann::detail::iter_impl::operator++
const iter_impl operator++(int)
post-increment (it++)
Definition: json.hpp:11822
nlohmann::detail::parser::sax_parse
bool sax_parse(SAX *sax, const bool strict=true)
Definition: json.hpp:10960
nlohmann::detail::iter_impl::operator=
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:11616
nlohmann::detail::iterator_traits< T *, enable_if_t< std::is_object< T >::value > >::pointer
T * pointer
Definition: json.hpp:3268
nlohmann::detail::error_handler_t::ignore
@ ignore
ignore invalid UTF-8 sequences
nlohmann::detail::boolean_function_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8158
nlohmann::basic_json::get_ref
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:20731
nlohmann::detail::external_constructor< value_t::array >::construct
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:4675
nlohmann::detail::dtoa_impl::grisu2_round
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:15741
nlohmann::detail::json_sax_dom_callback_parser::key
bool key(string_t &val)
Definition: json.hpp:6208
nlohmann::detail::wide_string_input_adapter::fill_buffer
void fill_buffer()
Definition: json.hpp:5625
nlohmann::detail::negation
Definition: json.hpp:3570
nlohmann::detail::output_string_adapter::write_character
void write_character(CharType c) override
Definition: json.hpp:13522
nlohmann::detail::detector< Default, void_t< Op< Args... > >, Op, Args... >::type
Op< Args... > type
Definition: json.hpp:3315
nlohmann::detail::unescape
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2568
nlohmann::detail::parse_event_t::array_start
@ array_start
the parser read [ and started to process a JSON array
nlohmann::detail::binary_writer::is_little_endian
const bool is_little_endian
whether we can assume little endianess
Definition: json.hpp:15177
nlohmann::detail::json_sax_acceptor::end_object
bool end_object()
Definition: json.hpp:6483
nlohmann::detail::to_chars
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).
Definition: json.hpp:16260
nlohmann::json_sax::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:5820
nlohmann::json_pointer::unflatten
static BasicJsonType unflatten(const BasicJsonType &value)
Definition: json.hpp:13262
nlohmann::detail::json_sax_dom_callback_parser::start_array
bool start_array(std::size_t len)
Definition: json.hpp:6261
altar_valkyrie.obj
obj
Definition: altar_valkyrie.py:33
nlohmann::detail::conjunction
Definition: json.hpp:3563
token
Definition: token.py:1
diamondslots.x
x
Definition: diamondslots.py:15
nlohmann::detail::lexer::skip_whitespace
void skip_whitespace()
Definition: json.hpp:8002
nlohmann::detail::error_handler_t::replace
@ replace
replace invalid UTF-8 sequences with U+FFFD
nlohmann::detail::binary_reader::operator=
binary_reader & operator=(const binary_reader &)=delete
nlohmann::basic_json::to_ubjson
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
Definition: json.hpp:24874
nlohmann::detail::serializer::UTF8_REJECT
static constexpr std::uint8_t UTF8_REJECT
Definition: json.hpp:16353
nlohmann::basic_json::is_discarded
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:20169
nlohmann::detail::iterator_input_adapter::char_type
typename std::iterator_traits< IteratorType >::value_type char_type
Definition: json.hpp:5439
nlohmann::detail::mapped_type_t
typename T::mapped_type mapped_type_t
Definition: json.hpp:3471
nlohmann::detail::json_sax_dom_callback_parser::handle_value
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
Definition: json.hpp:6345
nlohmann::detail::make_void::type
void type
Definition: json.hpp:3220
nlohmann::detail::container_input_adapter_factory_impl::container_input_adapter_factory
Definition: json.hpp:5696
JSON_HEDLEY_PURE
#define JSON_HEDLEY_PURE
Definition: json.hpp:1639
nlohmann::detail::span_input_adapter
Definition: json.hpp:5762
nlohmann::detail::json_sax_acceptor::start_object
bool start_object(std::size_t=std::size_t(-1))
Definition: json.hpp:6473
nlohmann::detail::json_ref::operator*
value_type const & operator*() const
Definition: json.hpp:13382
nlohmann::json_sax::parse_error
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
JSON_HEDLEY_UNLIKELY
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1566
nlohmann::basic_json::get_impl
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
Definition: json.hpp:20525
nlohmann::basic_json::get_impl_ptr
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
Definition: json.hpp:20231
nlohmann::basic_json::to_cbor
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Definition: json.hpp:24683
nlohmann::basic_json::json_value
json_value(const string_t &value)
constructor for strings
Definition: json.hpp:18457
nlohmann::detail::value_t::null
@ null
null value
nlohmann::detail::wide_string_input_adapter::base_adapter
BaseInputAdapter base_adapter
Definition: json.hpp:5622
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:3404
nlohmann::basic_json::from_bson
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.
Definition: json.hpp:25460
nlohmann::detail::external_constructor< value_t::object >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:4733
nlohmann::basic_json::rend
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:22222
nlohmann::json_sax::number_unsigned
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
nlohmann::ordered_map::operator[]
const T & operator[](const Key &key) const
Definition: json.hpp:17325
nlohmann::basic_json::set_parent
reference set_parent(reference j, std::size_t old_capacity=std::size_t(-1))
Definition: json.hpp:18705
nlohmann::detail::dtoa_impl::format_buffer
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
Definition: json.hpp:16175
nlohmann::detail::dtoa_impl::grisu2_digit_gen
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:15782
nlohmann::detail::dtoa_impl::diyfp
Definition: json.hpp:15252
nlohmann::detail::iterator_input_adapter_factory< IteratorType, enable_if_t< is_iterator_of_multibyte< IteratorType >::value > >::iterator_type
IteratorType iterator_type
Definition: json.hpp:5666
nlohmann::detail::json_reverse_iterator::operator+
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:12291
nlohmann::basic_json::size
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:22571
nlohmann::detail::value_t::object
@ object
object (unordered set of name/value pairs)
nlohmann::detail::json_sax_dom_parser::json_sax_dom_parser
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:5962
nlohmann::basic_json::basic_json_t
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
Definition: json.hpp:17579
nlohmann::detail::json_sax_dom_parser::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5953
nlohmann::detail::input_format_t::bson
@ bson
nlohmann::basic_json::push_back
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22896
nlohmann::detail::json_sax_dom_parser::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:5954
nlohmann::detail::detector< Default, void_t< Op< Args... > >, Op, Args... >::value_t
std::true_type value_t
Definition: json.hpp:3314
nlohmann::detail::iterator_input_adapter_factory::char_type
typename std::iterator_traits< iterator_type >::value_type char_type
Definition: json.hpp:5644
nlohmann::detail::iterator_input_adapter_factory::create
static adapter_type create(IteratorType first, IteratorType last)
Definition: json.hpp:5647
nlohmann::detail::position_t
struct to capture the start position of the current token
Definition: json.hpp:2587
nlohmann::detail::serializer::dump
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
Definition: json.hpp:16401
nlohmann::detail::dtoa_impl::boundaries::w
diyfp w
Definition: json.hpp:15372
nlohmann::detail::serializer::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:16348
nlohmann::detail::lexer::get_codepoint
int get_codepoint()
get codepoint from 4 hex characters following \u
Definition: json.hpp:6671
nlohmann::detail::is_complete_type
Definition: json.hpp:3634
nlohmann::basic_json::json_pointer
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:17620
nlohmann::detail::serializer::thousands_sep
const char thousands_sep
the locale's thousand separator character
Definition: json.hpp:17244
nlohmann::detail::binary_writer::to_char_type
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15141
nlohmann::detail::priority_tag
Definition: json.hpp:3170
nlohmann::detail::binary_writer::calc_bson_entry_header_size
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition: json.hpp:14483
nlohmann::basic_json::accept
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
Definition: json.hpp:24346
nlohmann::basic_json::object_comparator_t
std::less< StringType > object_comparator_t
Definition: json.hpp:17805
c
static event_registration c
Definition: citylife.cpp:425
nlohmann::basic_json::is_primitive
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:19868
nlohmann::basic_json::get_impl_ptr
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20273
nlohmann::basic_json::json_value
json_value(array_t &&value)
constructor for rvalue arrays
Definition: json.hpp:18487
nlohmann::json_pointer::json_pointer
json_pointer(const std::string &s="")
create JSON pointer
Definition: json.hpp:12384
disinfect.a
a
Definition: disinfect.py:13
nlohmann::detail::lexer::value_unsigned
number_unsigned_t value_unsigned
Definition: json.hpp:8126
nlohmann::basic_json::value
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21417
nlohmann::basic_json::type
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:19837
nlohmann::detail::binary_writer::write_bson_binary
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
Definition: json.hpp:14672
nlohmann::detail::parse_event_t::array_end
@ array_end
the parser read ] and finished processing a JSON array
nlohmann::detail::json_sax_acceptor::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6432
ring_occidental_mages.rest
rest
Definition: ring_occidental_mages.py:16
nlohmann::byte_container_with_subtype::has_subtype
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5120
nlohmann::detail::serializer::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:16349
nlohmann::basic_json::items
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22426
nlohmann::detail::out_of_range
exception indicating access out of the defined range
Definition: json.hpp:2971
nlohmann::detail::exception::m
std::runtime_error m
an exception object as storage for error messages
Definition: json.hpp:2732
nlohmann::detail::detected_or_t
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:3331
JSON_CATCH
#define JSON_CATCH(exception)
Definition: json.hpp:2268
nlohmann::detail::binary_writer::calc_bson_binary_size
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition: json.hpp:14645
nlohmann::detail::binary_reader::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8333
nlohmann::detail::detector::value_t
std::false_type value_t
Definition: json.hpp:3307
nlohmann::detail::external_constructor< value_t::array >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:4663
nlohmann::detail::invalid_iterator
exception indicating errors with iterators
Definition: json.hpp:2868
JSON_INTERNAL_CATCH
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2269
nlohmann::basic_json::operator=
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
Definition: json.hpp:19686
nlohmann::detail::json_sax_dom_parser::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:5955
nlohmann::basic_json::basic_json
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:19353
nlohmann::detail::binary_reader::unexpect_eof
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:10719
nlohmann::byte_container_with_subtype::byte_container_with_subtype
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5036
nlohmann::detail::json_sax_dom_callback_parser::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:6128
nlohmann::detail::json_sax_dom_parser::root
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:6110
nlohmann::detail::binary_reader::exception_message
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:10745
nlohmann::detail::lexer::scan_string
token_type scan_string()
scan a string literal
Definition: json.hpp:6756
nlohmann::detail::input_stream_adapter
Definition: json.hpp:5381
nlohmann::basic_json::allocator_type
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:17681
nlohmann::ordered_map::find
iterator find(const Key &key)
Definition: json.hpp:17401
nlohmann::detail::exception::name
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:2661
nlohmann::basic_json::value
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:21345
nlohmann::detail::input_format_t::cbor
@ cbor
nlohmann::detail::binary_reader::char_type
typename InputAdapterType::char_type char_type
Definition: json.hpp:8337
nlohmann::detail::is_constructible_string_type_impl
Definition: json.hpp:3716
nlohmann::detail::lexer::lexer
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:6625
nlohmann::detail::position_t::chars_read_current_line
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:2592
nlohmann::detail::iteration_proxy_value::empty_str
const string_type empty_str
an empty string (to return a reference for primitive values)
Definition: json.hpp:4370
nlohmann::ordered_map
Definition: json.hpp:3407
nlohmann::detail::binary_writer::write_bson_null
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
Definition: json.hpp:14552
nlohmann::json_pointer::operator/
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
Definition: json.hpp:12500
nlohmann::detail::priority_tag< 0 >
Definition: json.hpp:3171
nlohmann::detail::iteration_proxy_value::array_index
std::size_t array_index
an index for arrays (used to create key names)
Definition: json.hpp:4364
nlohmann::detail::binary_writer::write_bson_object_entry
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
Definition: json.hpp:14620
nlohmann::detail::iteration_proxy_value::anchor
IteratorType anchor
the iterator
Definition: json.hpp:4362
nlohmann::detail::lexer::ignore_comments
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
Definition: json.hpp:8104
nlohmann::detail::internal_iterator::object_iterator
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:11451
nlohmann::detail::make_void
Definition: json.hpp:3218
nlohmann::ordered_map::at
const T & at(const Key &key) const
Definition: json.hpp:17343
nlohmann::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3059
nlohmann::basic_json::is_binary
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:20142
nlohmann::detail::binary_writer::write_msgpack
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:13950
nlohmann::detail::from_json
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:3872
root
static char root[500]
Definition: mapper.cpp:304
nlohmann::ordered_map::emplace
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:17307
nlohmann::detail::nonesuch::nonesuch
nonesuch()=delete
nlohmann::detail::binary_writer::write_ubjson
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
Definition: json.hpp:14275
nlohmann::detail::to_json_fn
Definition: json.hpp:4897
nlohmann::detail::binary_reader::parse_ubjson_internal
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:10080
nlohmann::basic_json::to_bson
static std::vector< std::uint8_t > to_bson(const basic_json &j)
Serializes the given JSON object j to BSON and returns a vector containing the corresponding BSON-rep...
Definition: json.hpp:24952
nlohmann::detail::binary_reader::get_ubjson_size_type
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result)
determine the type and size for a container
Definition: json.hpp:10230
nlohmann::detail::binary_reader::get_string
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:10662
nlohmann::adl_serializer::from_json
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
Definition: json.hpp:4960
mad_mage_user.file
file
Definition: mad_mage_user.py:15
nlohmann::detail::json_sax_dom_parser::start_object
bool start_object(std::size_t len)
Definition: json.hpp:6015
bigchest.Target
Target
Definition: bigchest.py:23
nlohmann::detail::serializer::indent_char
const char indent_char
the indentation character
Definition: json.hpp:17252
nlohmann::basic_json::operator[]
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:25580
nlohmann::detail::json_reverse_iterator::key
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:12315
JSON_EXPLICIT
#define JSON_EXPLICIT
Definition: json.hpp:2512
nlohmann::detail::iter_impl::iter_impl
iter_impl()=default
nlohmann
namespace for Niels Lohmann
Definition: json.hpp:88
nlohmann::basic_json::json_value
json_value(const binary_t &value)
constructor for binary arrays (internal type)
Definition: json.hpp:18505
nlohmann::basic_json::object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:19326
nlohmann::detail::binary_writer
serialization to CBOR and MessagePack values
Definition: json.hpp:13576
nlohmann::detail::wide_string_input_adapter::utf8_bytes
std::array< std::char_traits< char >::int_type, 4 > utf8_bytes
a buffer for UTF-8 bytes
Definition: json.hpp:5631
nlohmann::detail::parse_event_t::object_end
@ object_end
the parser read } and finished processing a JSON object
nlohmann::detail::parser::callback
const parser_callback_t< BasicJsonType > callback
callback function
Definition: json.hpp:11296
nlohmann::detail::json_sax_dom_parser::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:5951
nlohmann::detail::binary_reader::get_cbor_array
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:9354
nlohmann::detail::primitive_iterator_t::set_end
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:11357
nlohmann::detail::dtoa_impl::diyfp::normalize_to
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:15359
nlohmann::detail::is_compatible_string_type
Definition: json.hpp:3711
nlohmann::basic_json::erase
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:21829
nlohmann::detail::has_from_json< BasicJsonType, T, enable_if_t< !is_basic_json< T >::value > >::serializer
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3520
nlohmann::detail::binary_writer::calc_bson_integer_size
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition: json.hpp:14560
nlohmann::detail::binary_reader::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8332
nlohmann::detail::binary_writer::get_cbor_float_prefix
static constexpr CharType get_cbor_float_prefix(double)
Definition: json.hpp:14818
nlohmann::detail::binary_reader::parse_bson_element_list
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:8609
nlohmann::detail::is_compatible_integer_type_impl< RealIntegerType, CompatibleNumberIntegerType, enable_if_t< std::is_integral< RealIntegerType >::value &&std::is_integral< CompatibleNumberIntegerType >::value &&!std::is_same< bool, CompatibleNumberIntegerType >::value > >::CompatibleLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3812
give.top
def top
Definition: give.py:42
nlohmann::detail::lexer_base::token_type::literal_or_value
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
nlohmann::ordered_map::erase
size_type erase(const Key &key)
Definition: json.hpp:17356
nlohmann::detail::json_reverse_iterator::json_reverse_iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:12254
nlohmann::ordered_map::operator[]
T & operator[](const Key &key)
Definition: json.hpp:17320
nlohmann::basic_json::to_bson
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
Definition: json.hpp:24975
nlohmann::basic_json::count
size_type count(KeyT &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:21933
Ice.tmp
int tmp
Definition: Ice.py:207
nlohmann::detail::binary_function_t
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8178
nlohmann::basic_json::push_back
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:22807
nlohmann::basic_json::meta
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:17735
nlohmann::detail::json_sax_dom_callback_parser::number_float
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6172
nlohmann::detail::input_stream_adapter::is
std::istream * is
the associated input stream
Definition: json.hpp:5428
JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:954
nlohmann::basic_json::back
reference back()
access the last element
Definition: json.hpp:21515
nlohmann::basic_json::get_impl_ptr
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20297
nlohmann::detail::lexer::token_string
std::vector< char_type > token_string
raw input token string (for error messages)
Definition: json.hpp:8116
nlohmann::basic_json::json_value
json_value(value_t t)
constructor for empty values of a given type
Definition: json.hpp:18385
nlohmann::basic_json::json_value
json_value(const object_t &value)
constructor for objects
Definition: json.hpp:18469
nlohmann::detail::primitive_iterator_t::get_value
constexpr difference_type get_value() const noexcept
Definition: json.hpp:11345
nlohmann::detail::external_constructor< value_t::number_integer >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:4640
nlohmann::detail::binary_writer::get_cbor_float_prefix
static constexpr CharType get_cbor_float_prefix(float)
Definition: json.hpp:14813
nlohmann::detail::primitive_iterator_t::is_end
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:11369
nlohmann::detail::iterator_input_adapter_factory
Definition: json.hpp:5641
nlohmann::detail::input_stream_adapter::get_character
std::char_traits< char >::int_type get_character()
Definition: json.hpp:5415
nlohmann::detail::json_sax_dom_parser
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:5948
nlohmann::basic_json::diff
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:26097
nlohmann::detail::integer_sequence::size
static constexpr std::size_t size() noexcept
Definition: json.hpp:3089
nlohmann::detail::value_t::number_float
@ number_float
number value (floating-point)
nlohmann::detail::primitive_iterator_t::operator--
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:11409
nlohmann::json_pointer
JSON Pointer.
Definition: json.hpp:3394
nlohmann::basic_json::operator!=
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
Definition: json.hpp:23839
nlohmann::json_pointer::parent_pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:12559
nlohmann::basic_json::erase
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:21697
nlohmann::detail::json_sax_dom_parser::number_integer
bool number_integer(number_integer_t val)
Definition: json.hpp:5985
nlohmann::detail::lexer_base::token_type::parse_error
@ parse_error
indicating a parse error
nlohmann::detail::other_error
exception indicating other library errors
Definition: json.hpp:3010
nlohmann::json_pointer::get_checked
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition: json.hpp:12882
nlohmann::detail::iteration_proxy_value::operator*
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
Definition: json.hpp:4378
nlohmann::detail::lexer::scan_comment
bool scan_comment()
scan a comment
Definition: json.hpp:7346
nlohmann::detail::json_reverse_iterator::operator+=
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12285
nlohmann::basic_json::merge_patch
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:26280
nlohmann::detail::iterator_types
Definition: json.hpp:3234
nlohmann::detail::lexer::operator=
lexer & operator=(lexer &)=delete
nlohmann::detail::lexer::current
char_int_type current
the current character
Definition: json.hpp:8107
nlohmann::detail::json_sax_acceptor::key
bool key(string_t &)
Definition: json.hpp:6478
nlohmann::detail::cbor_tag_handler_t::error
@ error
throw a parse_error exception in case of a tag
nlohmann::detail::from_json
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
Definition: json.hpp:4275
nlohmann::basic_json::json_value
json_value(string_t &&value)
constructor for rvalue strings
Definition: json.hpp:18463
nlohmann::detail::dtoa_impl::get_cached_power_for_binary_exponent
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:15523
nlohmann::basic_json::empty
bool empty() const noexcept
checks whether the container is empty.
Definition: json.hpp:22491
nlohmann::json_sax::string
virtual bool string(string_t &val)=0
a string was read
nlohmann::basic_json::rbegin
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition: json.hpp:22177
nlohmann::basic_json::operator!=
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:23850
nlohmann::detail::binary_reader::parse_cbor_internal
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:8677
nlohmann::basic_json::insert
iterator insert(const_iterator pos, basic_json &&val)
inserts element
Definition: json.hpp:23143
nlohmann::detail::value_t::number_integer
@ number_integer
number value (signed integer)
nlohmann::detail::binary_writer::write_bson_object
void write_bson_object(const typename BasicJsonType::object_t &value)
Definition: json.hpp:14797
nlohmann::basic_json::json_value
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
Definition: json.hpp:18499
diamondslots.object
object
Definition: diamondslots.py:34
nlohmann::detail::detector
Definition: json.hpp:3305
nlohmann::basic_json::array_t
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:17941
nlohmann::detail::binary_reader::ia
InputAdapterType ia
input adapter
Definition: json.hpp:10779
nlohmann::detail::binary_writer::ubjson_prefix
CharType ubjson_prefix(const BasicJsonType &j) const noexcept
determine the type prefix of container values
Definition: json.hpp:14984
nlohmann::detail::json_sax_dom_callback_parser::parser_callback_t
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6130
buf
StringBuffer * buf
Definition: readable.cpp:1565
nlohmann::basic_json::from_msgpack
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
Definition: json.hpp:25245
nlohmann::basic_json::get_impl_ptr
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20261
nlohmann::basic_json::json_value
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
Definition: json.hpp:18493
nlohmann::detail::input_stream_adapter::sb
std::streambuf * sb
Definition: json.hpp:5429
nlohmann::detail::is_constructible_tuple
Definition: json.hpp:3843
nlohmann::detail::json_sax_dom_callback_parser::json_sax_dom_callback_parser
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6133
nlohmann::detail::output_vector_adapter::output_vector_adapter
output_vector_adapter(std::vector< CharType > &vec) noexcept
Definition: json.hpp:13468
nlohmann::detail::iter_impl::operator-
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12100
nlohmann::detail::is_sax::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8214
nlohmann::detail::iteration_proxy_value::iterator_category
std::input_iterator_tag iterator_category
Definition: json.hpp:4357
nlohmann::detail::lexer::get_error_message
constexpr const JSON_HEDLEY_RETURNS_NON_NULL char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:7975
nlohmann::basic_json::operator<=
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:23996
nlohmann::basic_json::value
string_t value(const typename object_t::key_type &key, const char *default_value) const
overload for a default value of type const char*
Definition: json.hpp:21367
nlohmann::byte_container_with_subtype::clear_subtype
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5144
nlohmann::basic_json::from_ubjson
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
Definition: json.hpp:25346
nlohmann::detail::span_input_adapter::span_input_adapter
span_input_adapter(CharT b, std::size_t l)
Definition: json.hpp:5771
JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1300
nlohmann::detail::json_sax_dom_callback_parser::parse_error
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6311
nlohmann::json_pointer::to_string
std::string to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:12402
nlohmann::detail::json_sax_acceptor::string
bool string(string_t &)
Definition: json.hpp:6463
nlohmann::json_pointer::operator/
friend json_pointer operator/(const json_pointer &ptr, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:12541
nlohmann::detail::lexer::unget
void unget()
unget current character (read it again on next get)
Definition: json.hpp:7876
nlohmann::detail::binary_writer::write_bson_element
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
Definition: json.hpp:14735
nlohmann::detail::binary_writer::calc_bson_string_size
static std::size_t calc_bson_string_size(const string_t &value)
Definition: json.hpp:14530
nlohmann::detail::binary_writer::calc_bson_object_size
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
Definition: json.hpp:14782
nlohmann::detail::iteration_proxy_value::string_type
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:4358
nlohmann::detail::primitive_iterator_t::end_value
static constexpr difference_type end_value
Definition: json.hpp:11338
nlohmann::detail::json_sax_dom_parser::end_array
bool end_array()
Definition: json.hpp:6053
nlohmann::basic_json::to_bson
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
Definition: json.hpp:24967
nlohmann::detail::wide_string_input_helper< BaseInputAdapter, 2 >::fill_buffer
static void fill_buffer(BaseInputAdapter &input, std::array< std::char_traits< char >::int_type, 4 > &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
Definition: json.hpp:5536
nlohmann::detail::output_string_adapter::output_string_adapter
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:13518
board.elements
elements
Definition: board.py:55
nlohmann::detail::lexer_base::token_type::end_array
@ end_array
the character for array end ]
nlohmann::detail::is_compatible_type_impl
Definition: json.hpp:3827
nlohmann::detail::is_constructible_array_type
Definition: json.hpp:3796
nlohmann::basic_json::at
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:25623
nlohmann::detail::iterator_traits< T *, enable_if_t< std::is_object< T >::value > >::reference
T & reference
Definition: json.hpp:3269
nlohmann::basic_json::initializer_list_t
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:17628
nlohmann::detail::parser_callback_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:10851
nlohmann::detail::primitive_iterator_t::operator++
const primitive_iterator_t operator++(int) noexcept
Definition: json.hpp:11402
nlohmann::ordered_map::count
size_type count(const Key &key) const
Definition: json.hpp:17389
nlohmann::detail::parser::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:10863
nlohmann::detail::type_error::type_error
type_error(int id_, const char *what_arg)
Definition: json.hpp:2935
nlohmann::basic_json::insert
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:23121
nlohmann::detail::lexer::error_message
const char * error_message
a description of occurred lexer errors
Definition: json.hpp:8122
nlohmann::detail::iter_impl::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:11529
nlohmann::detail::serializer::undumped_chars
std::size_t undumped_chars
Definition: json.hpp:16693
nlohmann::detail::serializer::number_buffer
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition: json.hpp:17239
nlohmann::detail::binary_reader::get_ubjson_size_value
bool get_ubjson_size_value(std::size_t &result)
Definition: json.hpp:10153
nlohmann::basic_json::string
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:18362
nlohmann::detail::json_sax_dom_callback_parser::end_array
bool end_array()
Definition: json.hpp:6278
nlohmann::detail::input_stream_adapter::char_type
char char_type
Definition: json.hpp:5384
nlohmann::detail::binary_reader::get_ubjson_value
bool get_ubjson_value(const char_int_type prefix)
Definition: json.hpp:10271
nlohmann::detail::parser::accept
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:10952
nlohmann::detail::lexer_base
Definition: json.hpp:6536
nlohmann::detail::input_stream_adapter::~input_stream_adapter
~input_stream_adapter()
Definition: json.hpp:5386
m
static event_registration m
Definition: citylife.cpp:425
nlohmann::detail::iter_impl::other_iter_impl
friend other_iter_impl
allow basic_json to access private members
Definition: json.hpp:11511
nlohmann::detail::null_function_t
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8154
nlohmann::basic_json::get_impl_ptr
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20267
nlohmann::basic_json::swap
void swap(array_t &other)
exchanges the values
Definition: json.hpp:23521
nlohmann::basic_json::get_impl_ptr
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
Definition: json.hpp:20225
nlohmann::detail::parser::sax_parse_internal
bool sax_parse_internal(SAX *sax)
Definition: json.hpp:10979
nlohmann::detail::binary_reader::get_bson_binary
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
Definition: json.hpp:8505
nlohmann::json_pointer::operator/
friend json_pointer operator/(const json_pointer &ptr, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:12521
nlohmann::basic_json::parse
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
Definition: json.hpp:24285
nlohmann::detail::lexer
lexical analysis
Definition: json.hpp:6613
nlohmann::basic_json::to_cbor
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:24676
nlohmann::detail::json_ref::json_ref
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:13355
nlohmann::detail::iterator_traits< T *, enable_if_t< std::is_object< T >::value > >::iterator_category
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3265
nlohmann::detail::to_json_tuple_impl
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:4886
nlohmann::detail::json_sax_dom_parser::key
bool key(string_t &val)
Definition: json.hpp:6027
nlohmann::json_sax::boolean
virtual bool boolean(bool val)=0
a boolean value was read
nlohmann::detail::external_constructor< value_t::array >::construct
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:4653
nlohmann::detail::json_reverse_iterator::value
reference value() const
return the value of an iterator
Definition: json.hpp:12322
nlohmann::detail::primitive_iterator_t::operator+
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:11384
nlohmann::basic_json::json_value
json_value(object_t &&value)
constructor for rvalue objects
Definition: json.hpp:18475
disinfect.map
map
Definition: disinfect.py:4
nlohmann::detail::wide_string_input_adapter::get_character
std::char_traits< char >::int_type get_character() noexcept
Definition: json.hpp:5604
nlohmann::detail::is_compatible_integer_type_impl< RealIntegerType, CompatibleNumberIntegerType, enable_if_t< std::is_integral< RealIntegerType >::value &&std::is_integral< CompatibleNumberIntegerType >::value &&!std::is_same< bool, CompatibleNumberIntegerType >::value > >::RealLimits
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3811
nlohmann::detail::escape
std::string escape(std::string s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2554
nlohmann::detail::is_sax::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8212
nlohmann::detail::json_sax_dom_parser::boolean
bool boolean(bool val)
Definition: json.hpp:5979
NLOHMANN_BASIC_JSON_TPL
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2348
nlohmann::detail::parse_error::byte
const std::size_t byte
byte index of the parse error
Definition: json.hpp:2818
nlohmann::detail::iterator_input_adapter
Definition: json.hpp:5436
nlohmann::basic_json::swap
void swap(object_t &other)
exchanges the values
Definition: json.hpp:23554
nlohmann::detail::json_sax_dom_parser::number_unsigned
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:5991
nlohmann::byte_container_with_subtype::byte_container_with_subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5030
nlohmann::basic_json::cend
const_iterator cend() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:22147
nlohmann::basic_json::is_object
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:20076
nlohmann::detail::output_stream_adapter::output_stream_adapter
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:13493
nlohmann::detail::is_constructible_string_type
Definition: json.hpp:3730
nlohmann::basic_json::number_integer_t
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:18092
nlohmann::detail::primitive_iterator_t::set_begin
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:11351
NLOHMANN_JSON_VERSION_PATCH
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:35
nlohmann::detail::dtoa_impl::diyfp::sub
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:15265
nlohmann::detail::json_ref::json_ref
json_ref(Args &&... args)
Definition: json.hpp:13362
nlohmann::detail::output_adapter::output_adapter
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:13545
nlohmann::json_pointer::back
const std::string & back() const
return last reference token
Definition: json.hpp:12608
nlohmann::basic_json::parser
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
Definition: json.hpp:17586
nlohmann::basic_json::parse
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:24247
nlohmann::detail::json_ref
Definition: json.hpp:3458
make_face_from_files.args
args
Definition: make_face_from_files.py:37
nlohmann::detail::binary_writer::write_bson_string
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
Definition: json.hpp:14538
nlohmann::detail::is_constructible
Definition: json.hpp:3596
nlohmann::detail::json_sax_acceptor::start_array
bool start_array(std::size_t=std::size_t(-1))
Definition: json.hpp:6488
nlohmann::detail::get_template_function
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3501
rotate-tower.result
bool result
Definition: rotate-tower.py:13
nlohmann::detail::binary_reader::get_msgpack_binary
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
Definition: json.hpp:9910
nlohmann::detail::is_getable
Definition: json.hpp:3512
nlohmann::ordered_map::insert
void insert(InputIt first, InputIt last)
Definition: json.hpp:17448
nlohmann::detail::json_sax_dom_parser::binary
bool binary(binary_t &val)
Definition: json.hpp:6009
nlohmann::basic_json::operator<=
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:24018
make_face_from_files.parser
parser
Definition: make_face_from_files.py:24
nlohmann::detail::json_sax_dom_callback_parser::binary
bool binary(binary_t &val)
Definition: json.hpp:6184
nlohmann::detail::binary_reader::parse_bson_element_internal
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
Definition: json.hpp:8531
nlohmann::detail::has_non_default_from_json
Definition: json.hpp:3530
nlohmann::detail::json_sax_dom_parser::is_errored
constexpr bool is_errored() const
Definition: json.hpp:6073
nlohmann::detail::input_stream_adapter::input_stream_adapter
input_stream_adapter(std::istream &i)
Definition: json.hpp:5396
nlohmann::detail::parse_error
exception indicating a parse error
Definition: json.hpp:2780
nlohmann::detail::wide_string_input_adapter
Definition: json.hpp:5596
nlohmann::detail::primitive_iterator_t::is_begin
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:11363
nlohmann::basic_json::reverse_iterator
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:17693
nlohmann::detail::end_array_function_t
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:8196
nlohmann::basic_json::operator==
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:23712
nlohmann::detail::output_vector_adapter
output adapter for byte vectors
Definition: json.hpp:13465
nlohmann::detail::span_input_adapter::ia
contiguous_bytes_input_adapter ia
Definition: json.hpp:5787
nlohmann::detail::iteration_proxy_value::array_index_str
string_type array_index_str
a string representation of the array index
Definition: json.hpp:4368
nlohmann::detail::iterator_traits< T *, enable_if_t< std::is_object< T >::value > >::value_type
T value_type
Definition: json.hpp:3266
nlohmann::detail::wide_string_input_adapter::utf8_bytes_filled
std::size_t utf8_bytes_filled
number of valid bytes in the utf8_codes array
Definition: json.hpp:5636
nlohmann::detail::iter_impl
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:11506
nlohmann::json_pointer::reference_tokens
result reference_tokens
Definition: json.hpp:12723
nlohmann::detail::internal_iterator::array_iterator
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:11453
nlohmann::detail::json_sax_dom_callback_parser::root
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:6409
nlohmann::detail::external_constructor< value_t::string >::construct
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:4579
nlohmann::detail::value_t::string
@ string
string value
nlohmann::detail::parser::get_token
token_type get_token()
get next token from lexer
Definition: json.hpp:11260
nlohmann::detail::iter_impl::reference
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)
Definition: json.hpp:11543
nlohmann::json_sax::operator=
json_sax & operator=(const json_sax &)=default
nlohmann::detail::dtoa_impl::diyfp::mul
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:15277
nlohmann::detail::little_endianess
static bool little_endianess(int num=1) noexcept
determine system byte order
Definition: json.hpp:8315
nlohmann::detail::json_reverse_iterator::operator[]
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12309
nlohmann::detail::lexer_base::token_type::begin_object
@ begin_object
the character for object begin {
nlohmann::adl_serializer
default JSONSerializer template argument
Definition: json.hpp:3367
nlohmann::detail::lexer::add
void add(char_int_type c)
add a character to token_buffer
Definition: json.hpp:7903
nlohmann::detail::is_constructible_object_type
Definition: json.hpp:3692
nlohmann::detail::void_t
typename make_void< Ts... >::type void_t
Definition: json.hpp:3222
nlohmann::byte_container_with_subtype::operator==
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5042
nlohmann::basic_json::at
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:25666
nlohmann::basic_json::to_msgpack
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Definition: json.hpp:24778
nlohmann::basic_json::binary_t
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:18302
nlohmann::basic_json::m_value
json_value m_value
the value of the current element
Definition: json.hpp:24563
nlohmann::detail::is_detected_lazy
Definition: json.hpp:3322
nlohmann::json_sax::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:5819
nlohmann::ordered_map::erase
iterator erase(iterator pos)
Definition: json.hpp:17375
nlohmann::basic_json::get_impl_ptr
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
Definition: json.hpp:20219
nlohmann::basic_json::json_value
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
Definition: json.hpp:18381
nlohmann::detail::error_handler_t
error_handler_t
how to treat decoding errors
Definition: json.hpp:16337
nlohmann::detail::dtoa_impl::cached_power::f
std::uint64_t f
Definition: json.hpp:15511
JSON_HEDLEY_CONST
#define JSON_HEDLEY_CONST
Definition: json.hpp:1670
nlohmann::basic_json::string_t
StringType string_t
a type for a string
Definition: json.hpp:17994
nlohmann::basic_json::get_impl_ptr
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
Definition: json.hpp:20243
nlohmann::basic_json::from_msgpack
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
Definition: json.hpp:25229
nlohmann::detail::iterator_t
typename T::iterator iterator_t
Definition: json.hpp:3492
make_face_from_files.str
str
Definition: make_face_from_files.py:30
nlohmann::basic_json::array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:19282
nlohmann::detail::lexer::value_float
number_float_t value_float
Definition: json.hpp:8127
nlohmann::detail::dtoa_impl::reinterpret_bits
Target reinterpret_bits(const Source source)
Definition: json.hpp:15243
nlohmann::detail::binary_reader::get_bson_cstr
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition: json.hpp:8454
python_init.path
path
Definition: python_init.py:8
nlohmann::detail::value_type_t
typename T::value_type value_type_t
Definition: json.hpp:3477
nlohmann::detail::make_index_sequence
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3155
nlohmann::detail::binary_reader::get_cbor_binary
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
Definition: json.hpp:9260
nlohmann::basic_json::get_impl_ptr
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
Definition: json.hpp:20303
nlohmann::basic_json::operator>
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:24042
nlohmann::json_pointer::get_unchecked
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
Definition: json.hpp:12939
nlohmann::ordered_map::key_type
Key key_type
Definition: json.hpp:17290
nlohmann::detail::parser::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:10861
nlohmann::basic_json::to_msgpack
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
Definition: json.hpp:24783
nlohmann::json_sax::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:5822
nlohmann::json_sax::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:5823
nlohmann::basic_json::at
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:20899
nlohmann::detail::is_compatible_integer_type_impl
Definition: json.hpp:3801
nlohmann::basic_json::array
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:18360
nlohmann::detail::binary_writer::to_char_type
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15148
nlohmann::detail::dtoa_impl::grisu2
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition: json.hpp:16023
nlohmann::basic_json::emplace
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:23050
nlohmann::basic_json::operator>>
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:24481
nlohmann::detail::is_sax::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:8213
nlohmann::detail::file_input_adapter::m_file
std::FILE * m_file
the file pointer to read from
Definition: json.hpp:5368
nlohmann::detail::serializer::string_buffer
std::array< char, 512 > string_buffer
string buffer
Definition: json.hpp:17249
nlohmann::detail::binary_writer::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:13580
nlohmann::detail::external_constructor< value_t::number_unsigned >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:4627
nlohmann::basic_json::get
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20614
nlohmann::detail::lexer_base::token_type::value_separator
@ value_separator
the value separator ,
nlohmann::detail::json_reverse_iterator::difference_type
std::ptrdiff_t difference_type
Definition: json.hpp:12247
nlohmann::detail::iterator_traits< T *, enable_if_t< std::is_object< T >::value > >::difference_type
ptrdiff_t difference_type
Definition: json.hpp:3267
JSON_THROW
#define JSON_THROW(exception)
Definition: json.hpp:2266
nlohmann::detail::output_adapter::output_adapter
output_adapter(StringType &s)
Definition: json.hpp:13549
nlohmann::detail::json_sax_dom_callback_parser::number_integer
bool number_integer(number_integer_t val)
Definition: json.hpp:6160
nlohmann::detail::is_json_ref
Definition: json.hpp:3461
Ice.b
b
Definition: Ice.py:48
nlohmann::detail::cbor_tag_handler_t::store
@ store
store tags as binary type
nlohmann::detail::parse_event_t
parse_event_t
Definition: json.hpp:10833
nlohmann::detail::dtoa_impl::diyfp::normalize
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:15342
nlohmann::detail::integer_sequence::value_type
T value_type
Definition: json.hpp:3088
nlohmann::detail::iter_impl::operator++
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:11833
JSON_PRIVATE_UNLESS_TESTED
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2302
nlohmann::detail::iter_impl::set_end
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:11697
nlohmann::ordered_map::ordered_map
ordered_map(const Allocator &alloc=Allocator())
Definition: json.hpp:17300
nlohmann::basic_json::operator+=
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:22870
nlohmann::detail::parser
syntax analysis
Definition: json.hpp:10859
nlohmann::adl_serializer::from_json
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
Definition: json.hpp:4940
nlohmann::detail::serializer::binary_char_t
typename BasicJsonType::binary_t::value_type binary_char_t
Definition: json.hpp:16351
nlohmann::detail::wide_string_input_helper
Definition: json.hpp:5472
nlohmann::detail::span_input_adapter::span_input_adapter
span_input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5778
nlohmann::ordered_map::mapped_type
T mapped_type
Definition: json.hpp:17291
nlohmann::basic_json::get_impl_ptr
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20291
nlohmann::detail::iteration_proxy_value::key
const string_type & key() const
return key of the iterator
Definition: json.hpp:4405
nlohmann::detail::serializer::bytes
std::size_t bytes
Definition: json.hpp:16689
nlohmann::basic_json::update
void update(const_reference j)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23356
nlohmann::detail::lexer_base::token_type::value_float
@ value_float
an floating point number – use get_number_float() for actual value
nlohmann::detail::dtoa_impl::cached_power::e
int e
Definition: json.hpp:15512
CFweardisguise.tag
tag
Definition: CFweardisguise.py:25
nlohmann::detail::json_sax_acceptor::binary
bool binary(binary_t &)
Definition: json.hpp:6468
nlohmann::byte_container_with_subtype::container_type
BinaryType container_type
the type of the underlying container
Definition: json.hpp:5014
nlohmann::detail::lexer_base::token_type::literal_true
@ literal_true
the true literal
nlohmann::detail::iterator_input_adapter_factory::adapter_type
iterator_input_adapter< iterator_type > adapter_type
Definition: json.hpp:5645
nlohmann::detail::json_sax_dom_parser::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:5952
JSON_HEDLEY_RETURNS_NON_NULL
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:1899
JSON_HEDLEY_NON_NULL
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1458
nlohmann::json_pointer::operator/=
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:12480
nlohmann::basic_json::get_impl
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
Definition: json.hpp:20208
nlohmann::detail::binary_reader::get_number
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:10619
nlohmann::detail::json_reverse_iterator::reference
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:12251
nlohmann::detail::json_sax_dom_callback_parser
Definition: json.hpp:6122
nlohmann::detail::from_json_fn::operator()
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)))
Definition: json.hpp:4295
nlohmann::detail::iteration_proxy::end
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:4466
nlohmann::detail::json_sax_acceptor::number_integer
bool number_integer(number_integer_t)
Definition: json.hpp:6448
nlohmann::detail::iter_impl::operator>=
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:12023
nlohmann::basic_json::size_type
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:17678
nlohmann::detail::json_reverse_iterator::operator-
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12297
say.max
dictionary max
Definition: say.py:148
nlohmann::detail::serializer::operator=
serializer & operator=(const serializer &)=delete
nlohmann::detail::binary_writer::write_bson_integer
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
Definition: json.hpp:14570
nlohmann::detail::output_adapter_t
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:13461
nlohmann::basic_json::emplace_back
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:23000
nlohmann::detail::operator<
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:147
nlohmann::basic_json::operator==
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:23805
nlohmann::basic_json::rend
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition: json.hpp:22214
nlohmann::detail::iter_impl::iter_impl
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:11606
nlohmann::detail::span_input_adapter::get
contiguous_bytes_input_adapter && get()
Definition: json.hpp:5781
nlohmann::detail::output_string_adapter::str
StringType & str
Definition: json.hpp:13534
nlohmann::detail::is_constructible_array_type_impl
Definition: json.hpp:3757
nlohmann::detail::primitive_iterator_t::operator--
const primitive_iterator_t operator--(int) noexcept
Definition: json.hpp:11415
nlohmann::detail::input_format_t
input_format_t
the supported input formats
Definition: json.hpp:5333
nlohmann::detail::iter_impl::operator<=
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:12005
nlohmann::detail::parser::token_type
typename lexer_t::token_type token_type
Definition: json.hpp:10866
nlohmann::basic_json::sax_parse
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
Definition: json.hpp:24402
nlohmann::detail::parse_error::create
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
Definition: json.hpp:2793
nlohmann::detail::serializer::~serializer
~serializer()=default
nlohmann::detail::error_handler_t::strict
@ strict
throw a type_error exception in case of invalid UTF-8
nlohmann::detail::lexer::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:6618
nlohmann::detail::dtoa_impl::kGamma
constexpr int kGamma
Definition: json.hpp:15507
nlohmann::detail::binary_reader::parse_bson_array
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition: json.hpp:8647
nlohmann::basic_json::operator+=
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:22970
nlohmann::detail::external_constructor< value_t::binary >::construct
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:4592
nlohmann::json_pointer::pop_back
void pop_back()
remove last reference token
Definition: json.hpp:12584
nlohmann::detail::json_ref::value_ref
value_type const * value_ref
Definition: json.hpp:13394
nlohmann::detail::number_integer_function_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8162
nlohmann::detail::lexer::scan
token_type scan()
Definition: json.hpp:8011
nlohmann::detail::dtoa_impl::diyfp::f
std::uint64_t f
Definition: json.hpp:15256
nlohmann::basic_json::get_impl_ptr
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
Definition: json.hpp:20249
nlohmann::detail::iterator_traits
Definition: json.hpp:3252
nlohmann::detail::json_sax_acceptor::number_unsigned
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:6453
replace
Definition: replace.py:1
nlohmann::detail::json_sax_dom_callback_parser::number_unsigned
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6166
nlohmann::json_sax::number_float
virtual bool number_float(number_float_t val, const string_t &s)=0
an floating-point number was read
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
nlohmann::detail::wide_string_input_adapter::char_type
char char_type
Definition: json.hpp:5599
nlohmann::basic_json::object_t
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
Definition: json.hpp:17895
nlohmann::detail::json_sax_dom_parser::start_array
bool start_array(std::size_t len)
Definition: json.hpp:6041
nlohmann::basic_json::operator>=
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24110
nlohmann::detail::dtoa_impl::boundaries::minus
diyfp minus
Definition: json.hpp:15373
nlohmann::basic_json::operator>=
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24099
JSON_TRY
#define JSON_TRY
Definition: json.hpp:2267
nlohmann::detail::iter_impl::operator*
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:11736
nlohmann::basic_json::operator[]
const_reference operator[](const typename object_t::key_type &key) const
read-only access specified object element
Definition: json.hpp:21187
nlohmann::basic_json::get_ref
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:20718
nlohmann::detail::value_t::binary
@ binary
binary array (ordered collection of bytes)
nlohmann::basic_json::basic_json
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:19419
nlohmann::basic_json::type_name
const JSON_HEDLEY_RETURNS_NON_NULL char * type_name() const noexcept
return the type as string
Definition: json.hpp:24525
nlohmann::basic_json::operator>
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
Definition: json.hpp:24053
nlohmann::basic_json::items
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22434
nlohmann::basic_json::to_cbor
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
Definition: json.hpp:24688
nlohmann::detail::key_function_t
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:8186
nlohmann::detail::exception::id
const int id
the id of the exception
Definition: json.hpp:2655
nlohmann::basic_json::swap
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:23634
nlohmann::basic_json::const_reverse_iterator
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:17695
nlohmann::json_pointer::BasicJsonType
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no BasicJsonType()))
nlohmann::detail::nonesuch::~nonesuch
~nonesuch()=delete
nlohmann::json_sax::end_object
virtual bool end_object()=0
the end of an object was read
nlohmann::detail::serializer::serializer
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:16361
nlohmann::detail::replace_substring
void replace_substring(std::string &s, const std::string &f, const std::string &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2536
nlohmann::detail::lexer::scan_number
token_type scan_number()
scan a number literal
Definition: json.hpp:7471
nlohmann::byte_container_with_subtype::m_subtype
subtype_type m_subtype
Definition: json.hpp:5151
nlohmann::basic_json::erase
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:21794
nlohmann::detail::parse_event_t::value
@ value
the parser finished reading a JSON value
nlohmann::basic_json::number_unsigned
number_unsigned_t number_unsigned
number (unsigned integer)
Definition: json.hpp:18370
nlohmann::detail::iter_impl::operator<
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:11970
nlohmann::adl_serializer::to_json
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
Definition: json.hpp:4977
nlohmann::detail::external_constructor
Definition: json.hpp:4540
nlohmann::detail::iterator_types< It, void_t< typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category > >::value_type
typename It::value_type value_type
Definition: json.hpp:3243
nlohmann::basic_json::update
void update(const_iterator first, const_iterator last)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23407
nlohmann::detail::lexer::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6615
nlohmann::byte_container_with_subtype::subtype_type
std::uint64_t subtype_type
the type of the subtype
Definition: json.hpp:5016
nlohmann::byte_container_with_subtype::subtype
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5099
nlohmann::basic_json::number_unsigned_t
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:18163
nlohmann::basic_json::from_cbor
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
Definition: json.hpp:25102
nlohmann::basic_json::basic_json
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:19648
nlohmann::detail::internal_iterator::primitive_iterator
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:11455
nlohmann::detail::invalid_iterator::invalid_iterator
invalid_iterator(int id_, const char *what_arg)
Definition: json.hpp:2880
nlohmann::detail::binary_reader::parse_bson_internal
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:8429
nlohmann::detail::position_t::lines_read
std::size_t lines_read
the number of lines read
Definition: json.hpp:2594
nlohmann::detail::binary_reader::get_ubjson_string
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:10099
nlohmann::detail::lexer::char_int_type
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:6620
nlohmann::detail::value_t::number_unsigned
@ number_unsigned
number value (unsigned integer)
nlohmann::basic_json::json_value
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
Definition: json.hpp:18379
nlohmann::detail::lexer::get_decimal_point
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
Definition: json.hpp:6645
nlohmann::basic_json::max_size
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition: json.hpp:22649
nlohmann::detail::iter_impl::object_t
typename BasicJsonType::object_t object_t
Definition: json.hpp:11516
nlohmann::detail::is_compatible_type
Definition: json.hpp:3839
nlohmann::detail::binary_writer::write_bson_entry_header
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
Definition: json.hpp:14498
nlohmann::detail::parser::exception_message
std::string exception_message(const token_type expected, const std::string &context)
Definition: json.hpp:11265
nlohmann::detail::binary_reader
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:8329
nlohmann::detail::is_compatible_array_type
Definition: json.hpp:3753
nlohmann::detail::value_t::array
@ array
array (ordered collection of values)
nlohmann::detail::external_constructor< value_t::string >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:4568
nlohmann::detail::lexer_base::token_type::end_of_input
@ end_of_input
indicating the end of the input buffer
nlohmann::detail::binary_writer::get_ubjson_float_prefix
static constexpr CharType get_ubjson_float_prefix(double)
Definition: json.hpp:15070
board.element
list element
Definition: board.py:56
nlohmann::detail::from_json_function
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3498
nlohmann::detail::dtoa_impl::append_exponent
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:16123
nlohmann::detail::json_sax_dom_callback_parser::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6125
nlohmann::basic_json::boolean_t
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:18020
nlohmann::detail::is_sax::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8210
nlohmann::basic_json::end
const_iterator end() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:22117
nlohmann::json_pointer::push_back
void push_back(std::string &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:12636
nlohmann::detail::serializer::loc
const std::lconv * loc
the locale
Definition: json.hpp:17242
nlohmann::detail::binary_reader::sax
json_sax_t * sax
the SAX parser
Definition: json.hpp:10791
nlohmann::detail::json_ref::operator->
value_type const * operator->() const
Definition: json.hpp:13387
nlohmann::detail::dtoa_impl::boundaries::plus
diyfp plus
Definition: json.hpp:15374
nlohmann::ordered_map::ordered_map
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:17302
nlohmann::detail::binary_writer::write_compact_float
void write_compact_float(const number_float_t n, detail::input_format_t format)
Definition: json.hpp:15107
nlohmann::detail::iterator_input_adapter_factory::iterator_type
IteratorType iterator_type
Definition: json.hpp:5643
nlohmann::detail::iter_impl::array_t
typename BasicJsonType::array_t array_t
Definition: json.hpp:11517
nlohmann::detail::dtoa_impl::diyfp::diyfp
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:15259
nlohmann::basic_json::at
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:20852
nlohmann::detail::external_constructor< value_t::binary >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:4601
nlohmann::basic_json::contains
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:21966
nlohmann::detail::detected_t
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:3325
nlohmann::basic_json::get_impl
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition: json.hpp:20435
nlohmann::detail::end_object_function_t
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:8189
replace
void replace(const char *src, const char *key, const char *replacement, char *result, size_t resultsize)
Definition: utils.cpp:327
nlohmann::json_pointer::operator!=
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
Definition: json.hpp:13317
nlohmann::detail::is_compatible_array_type_impl
Definition: json.hpp:3734
nlohmann::detail::is_detected_convertible
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:3338
nlohmann::detail::json_sax_acceptor::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6434
nlohmann::detail::iteration_proxy_value::operator++
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:4384
nlohmann::basic_json::get_to
ValueType & get_to(ValueType &v) const
Definition: json.hpp:20671
nlohmann::ordered_map::insert
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:17425
nlohmann::detail::output_adapter_protocol
abstract output adapter interface
Definition: json.hpp:13446
nlohmann::basic_json::to_ubjson
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)
Definition: json.hpp:24883
nlohmann::detail::iteration_proxy_value::iteration_proxy_value
iteration_proxy_value(IteratorType it) noexcept
Definition: json.hpp:4373
make_face_from_files.out
out
Definition: make_face_from_files.py:81
nlohmann::detail::value_t::discarded
@ discarded
discarded by the parser callback function
nlohmann::basic_json::get_impl_ptr
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
Definition: json.hpp:20309
nlohmann::basic_json::begin
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:22036
nlohmann::basic_json::is_structured
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:19895
Floor.t
t
Definition: Floor.py:62
nlohmann::json_pointer::get_and_create
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
Definition: json.hpp:12736
nlohmann::basic_json::swap
void swap(string_t &other)
exchanges the values
Definition: json.hpp:23587
nlohmann::basic_json::swap
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:23620
nlohmann::detail::detector::type
Default type
Definition: json.hpp:3308
nlohmann::detail::json_sax_dom_parser::end_object
bool end_object()
Definition: json.hpp:6034
nlohmann::basic_json::~basic_json
~basic_json() noexcept
destructor
Definition: json.hpp:19720
nlohmann::json_pointer::get_checked
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
Definition: json.hpp:12987
nlohmann::basic_json::dump
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
Definition: json.hpp:19784
nlohmann::detail::primitive_iterator_t
Definition: json.hpp:11333
nlohmann::detail::external_constructor< value_t::string >::construct
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:4559
nlohmann::basic_json::json_serializer
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:17622
nlohmann::basic_json::push_back
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:22952
nlohmann::detail::iter_impl::BasicJsonType
friend BasicJsonType
Definition: json.hpp:11512
nlohmann::detail::is_iterator_traits
Definition: json.hpp:3612
nlohmann::basic_json::binary
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19179
std::less<::nlohmann::detail::value_t >::operator()
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:26358
nlohmann::detail::is_detected
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:3319
nlohmann::detail::binary_reader::chars_read
std::size_t chars_read
the number of characters read
Definition: json.hpp:10785
nlohmann::detail::value_t::boolean
@ boolean
boolean value
nlohmann::detail::parser::parser
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
Definition: json.hpp:10870
nlohmann::detail::lexer_base::token_type::value_string
@ value_string
a string – use get_string() for actual value
nlohmann::json_sax::start_object
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
nlohmann::basic_json::push_back
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:22844
nlohmann::json_pointer::operator/=
json_pointer & operator/=(std::string token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:12458
nlohmann::basic_json::operator>=
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24088
nlohmann::basic_json::accept
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
Definition: json.hpp:24339
nlohmann::basic_json::get_ref_impl
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
Definition: json.hpp:20326
nlohmann::basic_json::get_impl
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20538
nlohmann::detail::binary_writer::get_msgpack_float_prefix
static constexpr CharType get_msgpack_float_prefix(float)
Definition: json.hpp:14827
nlohmann::detail::input_format_t::msgpack
@ msgpack
nlohmann::json_pointer::result
json_pointer result
Definition: json.hpp:12722
nlohmann::detail::conditional_static_cast
T conditional_static_cast(U value)
Definition: json.hpp:3850
nlohmann::detail::lexer_base::token_type::literal_null
@ literal_null
the null literal
nlohmann::detail::external_constructor< value_t::object >::construct
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:4744
nlohmann::detail::is_sax_static_asserts::exception_t
typename BasicJsonType::exception exception_t
Definition: json.hpp:8246
nlohmann::detail::invalid_iterator::create
static invalid_iterator create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2872
nlohmann::basic_json::operator[]
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:21047
nlohmann::detail::serializer::decimal_point
const char decimal_point
the locale's decimal point character
Definition: json.hpp:17246
nlohmann::detail::lexer::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6617
nlohmann::detail::is_sax_static_asserts::number_integer_t
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8241
nlohmann::detail::binary_writer::calc_bson_element_size
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
Definition: json.hpp:14687
nlohmann::detail::lexer_base::token_type::literal_false
@ literal_false
the false literal
nlohmann::detail::is_getable::value
static constexpr bool value
Definition: json.hpp:3514
nlohmann::json_sax::number_integer
virtual bool number_integer(number_integer_t val)=0
an integer number was read
nlohmann::detail::serializer
Definition: json.hpp:16345
nlohmann::detail::iter_impl::operator>
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:12014
nlohmann::basic_json::find
iterator find(KeyT &&key)
find an element in a JSON object
Definition: json.hpp:21882
nlohmann::detail::binary_writer::write_bson_boolean
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
Definition: json.hpp:14510
nlohmann::detail::lexer::token_type
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:6623
nlohmann::basic_json::pointer
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:17684
nlohmann::basic_json::operator<
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:23881
nlohmann::basic_json::cbegin
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:22076
nlohmann::detail::output_stream_adapter
output adapter for output streams
Definition: json.hpp:13490
nlohmann::detail::primitive_iterator_t::begin_value
static constexpr difference_type begin_value
Definition: json.hpp:11337
nlohmann::detail::is_basic_json
Definition: json.hpp:3448
nlohmann::json_pointer::operator/=
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:12434
nlohmann::basic_json::begin
const_iterator begin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:22046
nlohmann::detail::is_iterator_of_multibyte::value_type
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:5656
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:3380
give.op
op
Definition: give.py:33
nlohmann::detail::primitive_iterator_t::difference_type
std::ptrdiff_t difference_type
Definition: json.hpp:11336
nlohmann::detail::json_reverse_iterator::operator++
const json_reverse_iterator operator++(int)
post-increment (it++)
Definition: json.hpp:12261
autojail.value
value
Definition: autojail.py:6
nlohmann::detail::iter_impl::~iter_impl
~iter_impl()=default
nlohmann::basic_json::get_impl_ptr
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20279
nlohmann::basic_json::set_parents
iterator set_parents(iterator it, typename iterator::difference_type count)
Definition: json.hpp:18692
nlohmann::detail::conjunction< B1 >
Definition: json.hpp:3564
nlohmann::basic_json::operator[]
reference operator[](const typename object_t::key_type &key)
access specified object element
Definition: json.hpp:21138
JSON_HEDLEY_LIKELY
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1565
nlohmann::json_sax::end_array
virtual bool end_array()=0
the end of an array was read
nlohmann::detail::is_sax::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8211
nlohmann::basic_json::from_bson
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.
Definition: json.hpp:25476
nlohmann::detail::json_sax_acceptor
Definition: json.hpp:6429
nlohmann::detail::serializer::bytes_after_last_accept
std::size_t bytes_after_last_accept
Definition: json.hpp:16692
nlohmann::detail::dtoa_impl::boundaries
Definition: json.hpp:15370
nlohmann::detail::out_of_range::out_of_range
out_of_range(int id_, const char *what_arg)
Definition: json.hpp:2983
nlohmann::basic_json::is_number
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:19969
nlohmann::detail::iter_impl::operator==
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:11925
nlohmann::detail::static_const::value
static constexpr T value
Definition: json.hpp:3177
nlohmann::basic_json::at
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:21001
nlohmann::detail::is_sax_static_asserts::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8245
nlohmann::detail::has_to_json
Definition: json.hpp:3545
nlohmann::basic_json::at
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:20950
nlohmann::detail::lexer::token_buffer
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
Definition: json.hpp:8119
nlohmann::basic_json::output_adapter_t
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
Definition: json.hpp:17608
nlohmann::detail::iteration_proxy_value
Definition: json.hpp:4350
nlohmann::detail::is_sax
Definition: json.hpp:8204
nlohmann::detail::binary_reader::get_cbor_object
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:9392
nlohmann::detail::iter_impl::operator+
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:12089
nlohmann::detail::binary_reader::parse_msgpack_internal
bool parse_msgpack_internal()
Definition: json.hpp:9448
std
Definition: json.hpp:4494
nlohmann::detail::json_sax_dom_parser::parse_error
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6061
init
void init(int argc, char **argv)
Definition: init.cpp:1087
nlohmann::detail::integer_sequence
Definition: json.hpp:3086
nlohmann::detail::json_reverse_iterator::operator++
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:12267
nlohmann::detail::primitive_iterator_t::operator-
constexpr friend difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11391
diamondslots.y
y
Definition: diamondslots.py:16
nlohmann::basic_json::operator!=
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:23828
nlohmann::basic_json::json_value
json_value(boolean_t v) noexcept
constructor for booleans
Definition: json.hpp:18377
nlohmann::detail::parser::parse
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:10892
nlohmann::detail::iterator_input_adapter_factory< IteratorType, enable_if_t< is_iterator_of_multibyte< IteratorType >::value > >::char_type
typename std::iterator_traits< iterator_type >::value_type char_type
Definition: json.hpp:5667
nlohmann::detail::is_constructible_object_type_impl< BasicJsonType, ConstructibleObjectType, enable_if_t< is_detected< mapped_type_t, ConstructibleObjectType >::value &&is_detected< key_type_t, ConstructibleObjectType >::value > >::object_t
typename BasicJsonType::object_t object_t
Definition: json.hpp:3673
receive.Value
Value
Definition: receive.py:27
nlohmann::detail::iter_impl::operator=
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:11641
nlohmann::detail::binary_reader::json_sax_t
SAX json_sax_t
Definition: json.hpp:8336
npc_dialog.index
int index
Definition: npc_dialog.py:102
nlohmann::detail::binary_reader::get_ubjson_object
bool get_ubjson_object()
Definition: json.hpp:10434
nlohmann::detail::input_format_t::json
@ json
nlohmann::detail::out_of_range::create
static out_of_range create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2975
nlohmann::detail::parser::m_lexer
lexer_t m_lexer
the lexer
Definition: json.hpp:11300
nlohmann::basic_json::to_ubjson
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
Definition: json.hpp:24889
nlohmann::json_pointer::push_back
void push_back(const std::string &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:12630
nlohmann::detail::binary_writer::get_msgpack_float_prefix
static constexpr CharType get_msgpack_float_prefix(double)
Definition: json.hpp:14832
nlohmann::detail::from_json_fn
Definition: json.hpp:4292
nlohmann::basic_json::insert
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
Definition: json.hpp:23220
nlohmann::detail::external_constructor< value_t::number_float >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:4614
nlohmann::detail::output_vector_adapter::write_character
void write_character(CharType c) override
Definition: json.hpp:13472
nlohmann::basic_json::iterator_wrapper
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
Definition: json.hpp:22344
nlohmann::json_pointer::flatten
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
Definition: json.hpp:13191
nlohmann::basic_json::operator<
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
Definition: json.hpp:23961
nlohmann::basic_json::basic_json
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:18974
nlohmann::detail::iteration_proxy::container
IteratorType::reference container
the container to iterate
Definition: json.hpp:4452
nlohmann::detail::json_sax_acceptor::number_float
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:6458
JSON_HEDLEY_DEPRECATED_FOR
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition: json.hpp:1248
nlohmann::ordered_map::Container
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:17292
nlohmann::ordered_map::require_input_iter
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:17445
nlohmann::detail::parse_error_function_t
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:8201
nlohmann::detail::get
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4475
nlohmann::detail::external_constructor< value_t::array >::construct
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:4688
nlohmann::detail::input_stream_adapter::input_stream_adapter
input_stream_adapter(input_stream_adapter &&rhs) noexcept
Definition: json.hpp:5405
nlohmann::detail::lexer_base::token_type::value_unsigned
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
nlohmann::detail::iterator_input_adapter::empty
bool empty() const
Definition: json.hpp:5464
nlohmann::detail::primitive_iterator_t::operator<
constexpr friend bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11379
nlohmann::basic_json::basic_json
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
Definition: json.hpp:18936
nlohmann::detail::lexer::get_number_integer
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:7914
nlohmann::ordered_map::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:17430
nlohmann::basic_json::operator==
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
Definition: json.hpp:23794
nlohmann::detail::parse_event_t::object_start
@ object_start
the parser read { and started to process a JSON object
nlohmann::detail::serializer::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:16347
nlohmann::basic_json::front
const_reference front() const
access the first element
Definition: json.hpp:21479
castle_read.key
key
Definition: castle_read.py:64
nlohmann::basic_json::number_float
number_float_t number_float
number (floating-point)
Definition: json.hpp:18372
nlohmann::basic_json::insert
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements
Definition: json.hpp:23273
nlohmann::detail::output_stream_adapter::stream
std::basic_ostream< CharType > & stream
Definition: json.hpp:13509
nlohmann::json_sax::json_sax
json_sax()=default
nlohmann::detail::binary_writer::get_ubjson_float_prefix
static constexpr CharType get_ubjson_float_prefix(float)
Definition: json.hpp:15065
nlohmann::detail::iter_impl::operator-=
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:12069
nlohmann::detail::json_sax_acceptor::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6433
nlohmann::detail::json_sax_acceptor::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6436
nlohmann::detail::parser::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:10864
C
#define C(w, e)
nlohmann::basic_json::get_impl
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
Definition: json.hpp:20502
nlohmann::detail::json_sax_dom_callback_parser::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6126
nlohmann::basic_json::json_value
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
Definition: json.hpp:18511
nlohmann::detail::number_float_function_t
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8170
nlohmann::basic_json::swap
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
Definition: json.hpp:23491
nlohmann::detail::lexer_base::token_type
token_type
token types for the parser
Definition: json.hpp:6540
nlohmann::detail::dtoa_impl::cached_power
Definition: json.hpp:15509
nlohmann::detail::internal_iterator
an iterator value
Definition: json.hpp:11448
NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:33
nlohmann::detail::json_sax_acceptor::boolean
bool boolean(bool)
Definition: json.hpp:6443
nlohmann::detail::iterator_types< It, void_t< typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category > >::reference
typename It::reference reference
Definition: json.hpp:3245
nlohmann::detail::json_ref::json_ref
json_ref(const value_type &value)
Definition: json.hpp:13351
nlohmann::basic_json::number_float_t
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:18231
nlohmann::basic_json::front
reference front()
access the first element
Definition: json.hpp:21471
nlohmann::detail::combine
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5179
nlohmann::detail::iter_impl::value_type
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:11532
nlohmann::detail::binary_reader::get_msgpack_object
bool get_msgpack_object(const std::size_t len)
Definition: json.hpp:10043
nlohmann::basic_json::is_number_integer
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:19998
disinfect.o
o
Definition: disinfect.py:11
nlohmann::detail::position_t::chars_read_total
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:2590
nlohmann::detail::is_compatible_object_type
Definition: json.hpp:3660
nlohmann::detail::binary_reader::binary_reader
binary_reader(InputAdapterType &&adapter) noexcept
create a binary reader
Definition: json.hpp:8346
NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:34
nlohmann::detail::lexer::strtof
static void strtof(float &f, const char *str, char **endptr) noexcept
Definition: json.hpp:7414
nlohmann::detail::from_json_tuple_impl_base
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4210
nlohmann::detail::parse_error::create
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2801
nlohmann::basic_json::operator[]
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:25552
nlohmann::detail::is_sax_static_asserts::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8242
nlohmann::byte_container_with_subtype::set_subtype
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5071
nlohmann::detail::parser::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:10862
nlohmann::detail::nonesuch::operator=
void operator=(nonesuch const &)=delete
nlohmann::detail::output_string_adapter
output adapter for basic_string
Definition: json.hpp:13515
nlohmann::detail::iter_impl::operator+
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:12078
nlohmann::basic_json::create
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
Definition: json.hpp:18310
nlohmann::detail::external_constructor< value_t::array >::construct
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:4704
nlohmann::detail::file_input_adapter::char_type
char char_type
Definition: json.hpp:5347
nlohmann::detail::lexer::next_byte_in_range
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
Definition: json.hpp:6719
nlohmann::detail::number_unsigned_function_t
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8166
nlohmann::detail::iter_impl::operator[]
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12140
nlohmann::basic_json::get_binary
const binary_t & get_binary() const
Definition: json.hpp:20805
nlohmann::basic_json::get_impl_ptr
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
Definition: json.hpp:20237
nlohmann::json_sax::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5821
nlohmann::byte_container_with_subtype::byte_container_with_subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5022
nlohmann::detail::json_reverse_iterator::operator--
const json_reverse_iterator operator--(int)
post-decrement (it–)
Definition: json.hpp:12273
nlohmann::detail::iterator_input_adapter_factory< IteratorType, enable_if_t< is_iterator_of_multibyte< IteratorType >::value > >::create
static adapter_type create(IteratorType first, IteratorType last)
Definition: json.hpp:5671
nlohmann::basic_json::is_number_unsigned
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:20026
nlohmann::detail::to_json_function
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3495
nlohmann::detail::json_sax_dom_callback_parser::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6127
nlohmann::detail::json_sax_dom_callback_parser::start_object
bool start_object(std::size_t len)
Definition: json.hpp:6190
nlohmann::detail::primitive_iterator_t::operator-=
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:11428
nlohmann::detail::lexer::~lexer
~lexer()=default
nlohmann::detail::iteration_proxy::iteration_proxy
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:4456
nlohmann::detail::is_sax_static_asserts::number_float_t
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8243
nlohmann::basic_json::operator<<
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
Definition: json.hpp:24155
nlohmann::basic_json::clear
void clear() noexcept
clears the contents
Definition: json.hpp:22728
nlohmann::basic_json::operator>>
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
Definition: json.hpp:24179
nlohmann::detail::wide_string_input_adapter::utf8_bytes_index
std::size_t utf8_bytes_index
index to the utf8_codes array for the next valid byte
Definition: json.hpp:5634
nlohmann::detail::nonesuch
Definition: json.hpp:3291
nlohmann::ordered_map::ordered_map
ordered_map(std::initializer_list< T > init, const Allocator &alloc=Allocator())
Definition: json.hpp:17304
nlohmann::basic_json::binary
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19226
nlohmann::detail::other_error::other_error
other_error(int id_, const char *what_arg)
Definition: json.hpp:3022
nlohmann::basic_json::is_null
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:19917
nlohmann::basic_json::from_cbor
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
Definition: json.hpp:25085
nlohmann::detail::iterator_input_adapter::current
IteratorType current
Definition: json.hpp:5458
nlohmann::basic_json::insert
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts elements
Definition: json.hpp:23172
nlohmann::detail::reference_t
typename T::reference reference_t
Definition: json.hpp:3486
nlohmann::basic_json::crend
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:22280
nlohmann::detail::index_sequence_for
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3163
nlohmann::detail::iteration_proxy_value::operator!=
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:4399
nlohmann::detail::serializer::error_handler
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:17257
nlohmann::basic_json::patch
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
Definition: json.hpp:25791
nlohmann::json_pointer::reference_tokens
std::vector< std::string > reference_tokens
the reference tokens
Definition: json.hpp:13324
nlohmann::detail::identity_tag
Definition: json.hpp:3194
nlohmann::detail::binary_reader::current
char_int_type current
the current character
Definition: json.hpp:10782
nlohmann::detail::lexer::next_unget
bool next_unget
whether the next get() call should just return current
Definition: json.hpp:8110
nlohmann::detail::binary_reader::get_binary
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
Definition: json.hpp:10695
nlohmann::detail::lexer::decimal_point_char
const char_int_type decimal_point_char
the decimal point
Definition: json.hpp:8130
nlohmann::detail::dtoa_impl::kAlpha
constexpr int kAlpha
Definition: json.hpp:15506
nlohmann::detail::binary_writer::write_number_with_ubjson_prefix
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
Definition: json.hpp:14844
nlohmann::detail::binary_reader::get_msgpack_string
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:9828
nlohmann::detail::iteration_proxy_value::array_index_last
std::size_t array_index_last
last stringified array index
Definition: json.hpp:4366
nlohmann::detail::is_compatible_object_type_impl
Definition: json.hpp:3641
nlohmann::detail::is_sax::value
static constexpr bool value
Definition: json.hpp:8218
report.error
def error(pl)
Definition: report.py:43
nlohmann::detail::parse_error::position_string
static std::string position_string(const position_t &pos)
Definition: json.hpp:2824
nlohmann::detail::file_input_adapter
Definition: json.hpp:5344
nlohmann::detail::binary_writer::write_bson_double
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
Definition: json.hpp:14520
nlohmann::detail::is_default_constructible
Definition: json.hpp:3576
nlohmann::detail::json_sax_dom_callback_parser::end_object
bool end_object()
Definition: json.hpp:6225
nlohmann::detail::lexer_base::token_type::end_object
@ end_object
the character for object end }
nlohmann::detail::binary_writer::write_bson_array
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
Definition: json.hpp:14653
nlohmann::detail::is_compatible_integer_type
Definition: json.hpp:3822
nlohmann::basic_json::erase
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21582
nlohmann::detail::container_input_adapter_factory_impl::container_input_adapter_factory< ContainerType, void_t< decltype(begin(std::declval< ContainerType >()), end(std::declval< ContainerType >()))> >::adapter_type
decltype(input_adapter(begin(std::declval< ContainerType >()), end(std::declval< ContainerType >()))) adapter_type
Definition: json.hpp:5702
nlohmann::basic_json::get_ptr
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20385
nlohmann::detail::is_compatible_string_type_impl
Definition: json.hpp:3698
nlohmann::detail::string_function_t
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8174
nlohmann::detail::input_stream_adapter::operator=
input_stream_adapter & operator=(input_stream_adapter &)=delete
nlohmann::basic_json::is_array
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:20098
nlohmann::detail::iteration_proxy_value::operator==
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:4393
nlohmann::detail::iter_impl::m_it
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:12203
nlohmann::json_sax::start_array
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
nlohmann::detail::key_type_t
typename T::key_type key_type_t
Definition: json.hpp:3474
nlohmann::detail::binary_reader::sax_parse
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)
Definition: json.hpp:8367
nlohmann::detail::lexer_base::token_type_name
JSON_HEDLEY_RETURNS_NON_NULL static const JSON_HEDLEY_CONST char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:6564
nlohmann::detail::iter_impl::difference_type
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:11534
nlohmann::basic_json::get_to
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:20682
nlohmann::detail::from_json_array_impl
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4027
nlohmann::detail::binary_reader::get_ubjson_high_precision_number
bool get_ubjson_high_precision_number()
Definition: json.hpp:10509
nlohmann::json_sax
SAX interface.
Definition: json.hpp:5817
nlohmann::basic_json::insert
void insert(const_iterator first, const_iterator last)
inserts elements
Definition: json.hpp:23314
nlohmann::detail::iterator_input_adapter::end
IteratorType end
Definition: json.hpp:5459
nlohmann::detail::binary_reader::char_int_type
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:8338
nlohmann::basic_json::number_integer
number_integer_t number_integer
number (integer)
Definition: json.hpp:18368
nlohmann::detail::lexer::scan_literal
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
Definition: json.hpp:7802
nlohmann::detail::binary_reader::get_bson_string
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition: json.hpp:8484
nlohmann::detail::lexer::value_integer
number_integer_t value_integer
Definition: json.hpp:8125
nlohmann::detail::file_input_adapter::file_input_adapter
file_input_adapter(std::FILE *f) noexcept
Definition: json.hpp:5350
nlohmann::basic_json::crbegin
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:22251
replace.current
current
Definition: replace.py:64
nlohmann::detail::dtoa_impl::cached_power::k
int k
Definition: json.hpp:15513
nlohmann::detail::iter_impl::operator!=
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:11961
nlohmann::detail::container_input_adapter_factory_impl::container_input_adapter_factory< ContainerType, void_t< decltype(begin(std::declval< ContainerType >()), end(std::declval< ContainerType >()))> >::create
static adapter_type create(const ContainerType &container)
Definition: json.hpp:5704
nlohmann::json_sax::binary
virtual bool binary(binary_t &val)=0
a binary string was read
nlohmann::basic_json::is_boolean
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:19939
nlohmann::basic_json::destroy
void destroy(value_t t)
Definition: json.hpp:18516
nlohmann::detail::lexer::get
char_int_type get()
Definition: json.hpp:7839
nlohmann::detail::binary_reader::get
char_int_type get()
get next character from the input
Definition: json.hpp:10585
nlohmann::detail::binary_reader::get_msgpack_array
bool get_msgpack_array(const std::size_t len)
Definition: json.hpp:10021
nlohmann::basic_json::json_value
json_value(const array_t &value)
constructor for arrays
Definition: json.hpp:18481
nlohmann::basic_json::get_impl_ptr
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20255
nlohmann::basic_json::difference_type
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:17676
nlohmann::json_pointer::contains
bool contains(const BasicJsonType *ptr) const
Definition: json.hpp:13035
nlohmann::detail::parser::allow_exceptions
const bool allow_exceptions
whether to throw exceptions in case of errors
Definition: json.hpp:11302
nlohmann::basic_json::get_ptr
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20372
nlohmann::detail::iteration_proxy
proxy class for the items() function
Definition: json.hpp:4448
nlohmann::detail::iter_impl::key
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:12178
nlohmann::detail::binary_reader::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:8334
nlohmann::detail::external_constructor< value_t::object >::construct
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:4723
JSON_ASSERT
#define JSON_ASSERT(x)
Definition: json.hpp:2295
nlohmann::detail::to_json
void to_json(BasicJsonType &j, const T &b)
Definition: json.hpp:4880
nlohmann::detail::exception::diagnostics
static std::string diagnostics(const BasicJsonType &leaf_element)
Definition: json.hpp:2667
nlohmann::detail::iterator_input_adapter::iterator_input_adapter
iterator_input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5441
nlohmann::detail::cbor_tag_handler_t
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:8301
nlohmann::detail::iterator_types< It, void_t< typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category > >::difference_type
typename It::difference_type difference_type
Definition: json.hpp:3242
nlohmann::detail::json_reverse_iterator::operator-
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:12303
nlohmann::detail::json_sax_acceptor::parse_error
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:6498
nlohmann::detail::binary_reader::get_ubjson_array
bool get_ubjson_array()
Definition: json.hpp:10372
nlohmann::detail::lexer::char_type
typename InputAdapterType::char_type char_type
Definition: json.hpp:6619
nlohmann::detail::input_format_t::ubjson
@ ubjson
nlohmann::detail::lexer::position
position_t position
the start position of the current token
Definition: json.hpp:8113
nlohmann::detail::from_json_tuple_impl
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 >>, priority_tag< 0 >)
Definition: json.hpp:4216
nlohmann::detail::parse_event_t::key
@ key
the parser read a key of a value in an object
nlohmann::detail::pointer_t
typename T::pointer pointer_t
Definition: json.hpp:3483
nlohmann::detail::binary_reader::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8335
nlohmann::basic_json::binary
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)
Definition: json.hpp:19236
nlohmann::json_pointer::array_index
static BasicJsonType::size_type array_index(const std::string &s)
Definition: json.hpp:12671
nlohmann::detail::lexer_base::token_type::begin_array
@ begin_array
the character for array begin [
nlohmann::byte_container_with_subtype::m_has_subtype
bool m_has_subtype
Definition: json.hpp:5152
nlohmann::basic_json::is_number_float
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:20054
nlohmann::detail::serializer::ensure_ascii
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition: json.hpp:16686
nlohmann::detail::dtoa_impl::diyfp::e
int e
Definition: json.hpp:15257
make_face_from_files.default
default
Definition: make_face_from_files.py:30
nlohmann::detail::iter_impl::pointer
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)
Definition: json.hpp:11538
nlohmann::detail::iter_impl::operator--
const iter_impl operator--(int)
post-decrement (it–)
Definition: json.hpp:11873
nlohmann::basic_json::json_value
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
Definition: json.hpp:18383
nlohmann::json_sax::key
virtual bool key(string_t &val)=0
an object key was read
nlohmann::detail::lexer::ia
InputAdapterType ia
input adapter
Definition: json.hpp:8101
nlohmann::byte_container_with_subtype
an internal type for a backed binary type
Definition: json.hpp:5010
nlohmann::detail::is_sax_static_asserts::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:8244
nlohmann::detail::binary_reader::~binary_reader
~binary_reader()=default
nlohmann::detail::binary_writer::binary_writer
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:13588
nlohmann::detail::static_const
Definition: json.hpp:3175
nlohmann::basic_json::basic_json
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:19556
nlohmann::detail::lexer::get_number_unsigned
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:7920
nlohmann::detail::output_stream_adapter::write_character
void write_character(CharType c) override
Definition: json.hpp:13497
nlohmann::detail::iterator_types< It, void_t< typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category > >::pointer
typename It::pointer pointer
Definition: json.hpp:3244
nlohmann::ordered_map::find
const_iterator find(const Key &key) const
Definition: json.hpp:17413
nlohmann::detail::output_adapter::output_adapter
output_adapter(std::vector< CharType > &vec)
Definition: json.hpp:13541
nlohmann::detail::binary_writer::oa
output_adapter_t< CharType > oa
the output
Definition: json.hpp:15180
nlohmann::detail::is_sax::exception_t
typename BasicJsonType::exception exception_t
Definition: json.hpp:8215
nlohmann::detail::primitive_iterator_t::operator==
constexpr friend bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11374
nlohmann::detail::lexer_base::token_type::value_integer
@ value_integer
a signed integer – use get_number_integer() for actual value
altar_valkyrie.res
int res
Definition: altar_valkyrie.py:74
nlohmann::json_pointer::operator==
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
Definition: json.hpp:13300
nlohmann::detail::json_sax_acceptor::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:6435
nlohmann::detail::json_sax_dom_parser::number_float
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:5997
nlohmann::detail::binary_writer::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:13579
nlohmann::detail::iterator_input_adapter::get_character
std::char_traits< char_type >::int_type get_character()
Definition: json.hpp:5445
nlohmann::basic_json::operator[]
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:21100
nlohmann::detail::json_sax_acceptor::end_array
bool end_array()
Definition: json.hpp:6493
nlohmann::detail::dtoa_impl::find_largest_pow10
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:15687
nlohmann::detail::json_reverse_iterator::base_iterator
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:12249
nlohmann::detail::lexer_base::token_type::uninitialized
@ uninitialized
indicating the scanner is uninitialized
nlohmann::detail::parser::last_token
token_type last_token
the type of the last read token
Definition: json.hpp:11298
nlohmann::detail::binary_writer::calc_bson_unsigned_size
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition: json.hpp:14588
nlohmann::basic_json::binary
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)
Definition: json.hpp:19216
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
nlohmann::detail::json_reverse_iterator::operator--
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:12279
nlohmann::detail::binary_writer::string_t
typename BasicJsonType::string_t string_t
Definition: json.hpp:13578
nlohmann::basic_json::insert_iterator
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:23082
nlohmann::detail::binary_reader::get_ignore_noop
char_int_type get_ignore_noop()
Definition: json.hpp:10594
nlohmann::json_pointer::split
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
Definition: json.hpp:13123
nlohmann::detail::external_constructor< value_t::boolean >::construct
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:4546
nlohmann::detail::iter_impl::value
reference value() const
return the value of an iterator
Definition: json.hpp:12194
nlohmann::basic_json::operator+=
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:22834
nlohmann::detail::json_reverse_iterator::json_reverse_iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:12258
nlohmann::json_pointer::result
return result
Definition: json.hpp:12724
nlohmann::byte_container_with_subtype::operator!=
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5048
nlohmann::detail::contiguous_bytes_input_adapter
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:5736
nlohmann::detail::to_json
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:4763
nlohmann::byte_container_with_subtype::byte_container_with_subtype
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5018
nlohmann::detail::is_constructible_object_type_impl
Definition: json.hpp:3665
nlohmann::detail::json_sax_dom_callback_parser::is_errored
constexpr bool is_errored() const
Definition: json.hpp:6323
nlohmann::detail::binary_writer::write_bson
void write_bson(const BasicJsonType &j)
Definition: json.hpp:13597
nlohmann::basic_json::const_pointer
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:17686
nlohmann::detail::iter_impl::operator+=
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12032
nlohmann::detail::output_adapter
Definition: json.hpp:13538
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
nlohmann::detail::lexer_base::token_type::name_separator
@ name_separator
the name separator :
nlohmann::basic_json::end
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:22107
nlohmann::basic_json::get_to
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:20658
nlohmann::detail::index_sequence
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:3101
nlohmann::detail::iterator_category_t
typename T::iterator_category iterator_category_t
Definition: json.hpp:3489
nlohmann::detail::json_sax_dom_callback_parser::boolean
bool boolean(bool val)
Definition: json.hpp:6154
nlohmann::basic_json::get
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)
Definition: json.hpp:20573
nlohmann::detail::json_ref::value_type
BasicJsonType value_type
Definition: json.hpp:13345
nlohmann::detail::make_integer_sequence
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3147
nlohmann::detail::to_json_fn::operator()
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())
Definition: json.hpp:4900
nlohmann::basic_json::swap
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
Definition: json.hpp:23458
give.name
name
Definition: give.py:27
nlohmann::detail::lexer::get_string
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:7932
nlohmann::basic_json::get_binary
binary_t & get_binary()
Definition: json.hpp:20794
nlohmann::detail::from_json_inplace_array_impl
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)>>, index_sequence< Idx... >)
Definition: json.hpp:4110
nlohmann::detail::has_non_default_from_json< BasicJsonType, T, enable_if_t< !is_basic_json< T >::value > >::serializer
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3535
nlohmann::detail::is_detected_exact
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:3334
nlohmann::detail::lexer::skip_bom
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:7988
nlohmann::detail::serializer::number_unsigned_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:16350
nlohmann::detail::utility_internal::Extend
Definition: json.hpp:3107
nlohmann::basic_json::contains
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:21997
std::hash< nlohmann::json >::operator()
std::size_t operator()(const nlohmann::json &j) const
return a hash value for a JSON object
Definition: json.hpp:26342
nlohmann::basic_json::basic_json
basic_json(const JsonRef &ref)
Definition: json.hpp:19529
nlohmann::detail::json_sax_dom_callback_parser::binary_t
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6129
nlohmann::detail::uncvref_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:3045