json.h
Go to the documentation of this file.
1 
4 // //////////////////////////////////////////////////////////////////////
5 // Beginning of content of file: LICENSE
6 // //////////////////////////////////////////////////////////////////////
7 
8 /*
9 The JsonCpp library's source code, including accompanying documentation,
10 tests and demonstration applications, are licensed under the following
11 conditions...
12 
13 Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
14 jurisdictions which recognize such a disclaimer. In such jurisdictions,
15 this software is released into the Public Domain.
16 
17 In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
18 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
19 The JsonCpp Authors, and is released under the terms of the MIT License (see below).
20 
21 In jurisdictions which recognize Public Domain property, the user of this
22 software may choose to accept it either as 1) Public Domain, 2) under the
23 conditions of the MIT License (see below), or 3) under the terms of dual
24 Public Domain/MIT License conditions described here, as they choose.
25 
26 The MIT License is about as close to Public Domain as a license can get, and is
27 described in clear, concise terms at:
28 
29  http://en.wikipedia.org/wiki/MIT_License
30 
31 The full text of the MIT License follows:
32 
33 ========================================================================
34 Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
35 
36 Permission is hereby granted, free of charge, to any person
37 obtaining a copy of this software and associated documentation
38 files (the "Software"), to deal in the Software without
39 restriction, including without limitation the rights to use, copy,
40 modify, merge, publish, distribute, sublicense, and/or sell copies
41 of the Software, and to permit persons to whom the Software is
42 furnished to do so, subject to the following conditions:
43 
44 The above copyright notice and this permission notice shall be
45 included in all copies or substantial portions of the Software.
46 
47 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
51 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
52 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
53 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54 SOFTWARE.
55 ========================================================================
56 (END LICENSE TEXT)
57 
58 The MIT license is compatible with both the GPL and commercial
59 software, affording one all of the rights of Public Domain with the
60 minor nuisance of being required to keep the above copyright notice
61 and license text in the source code. Note also that by accepting the
62 Public Domain "license" you can re-license your copy using whatever
63 license you like.
64 
65 */
66 
67 // //////////////////////////////////////////////////////////////////////
68 // End of content of file: LICENSE
69 // //////////////////////////////////////////////////////////////////////
70 
71 
72 
73 
74 
75 #ifndef JSON_AMALGAMATED_H_INCLUDED
76 # define JSON_AMALGAMATED_H_INCLUDED
77 #define JSON_IS_AMALGAMATION
80 
81 // //////////////////////////////////////////////////////////////////////
82 // Beginning of content of file: include/json/version.h
83 // //////////////////////////////////////////////////////////////////////
84 
85 // DO NOT EDIT. This file (and "version") is generated by CMake.
86 // Run CMake configure step to update it.
87 #ifndef JSON_VERSION_H_INCLUDED
88 #define JSON_VERSION_H_INCLUDED
89 
90 #define JSONCPP_VERSION_STRING "1.8.4"
91 #define JSONCPP_VERSION_MAJOR 1
92 #define JSONCPP_VERSION_MINOR 8
93 #define JSONCPP_VERSION_PATCH 4
94 #define JSONCPP_VERSION_QUALIFIER
95 #define JSONCPP_VERSION_HEXA \
96  ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
97  (JSONCPP_VERSION_PATCH << 8))
98 
99 #ifdef JSONCPP_USING_SECURE_MEMORY
100 #undef JSONCPP_USING_SECURE_MEMORY
101 #endif
102 #define JSONCPP_USING_SECURE_MEMORY 0
103 // If non-zero, the library zeroes any memory that it has allocated before
104 // it frees its memory.
105 
106 #endif // JSON_VERSION_H_INCLUDED
107 
108 // //////////////////////////////////////////////////////////////////////
109 // End of content of file: include/json/version.h
110 // //////////////////////////////////////////////////////////////////////
111 
112 
113 
114 
115 
116 
117 // //////////////////////////////////////////////////////////////////////
118 // Beginning of content of file: include/json/allocator.h
119 // //////////////////////////////////////////////////////////////////////
120 
121 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
122 // Distributed under MIT license, or public domain if desired and
123 // recognized in your jurisdiction.
124 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
125 
126 #ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
127 #define CPPTL_JSON_ALLOCATOR_H_INCLUDED
128 
129 #include <cstring>
130 #include <memory>
131 
132 #pragma pack(push, 8)
133 
134 namespace Json {
135 template <typename T> class SecureAllocator {
136 public:
137  // Type definitions
138  using value_type = T;
139  using pointer = T*;
140  using const_pointer = const T*;
141  using reference = T&;
142  using const_reference = const T&;
143  using size_type = std::size_t;
144  using difference_type = std::ptrdiff_t;
145 
150  // allocate using "global operator new"
151  return static_cast<pointer>(::operator new(n * sizeof(T)));
152  }
153 
161  void deallocate(volatile pointer p, size_type n) {
162  std::memset(p, 0, n * sizeof(T));
163  // free using "global operator delete"
164  ::operator delete(p);
165  }
166 
170  template <typename... Args> void construct(pointer p, Args&&... args) {
171  // construct using "placement new" and "perfect forwarding"
172  ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
173  }
174 
175  size_type max_size() const { return size_t(-1) / sizeof(T); }
176 
177  pointer address(reference x) const { return std::addressof(x); }
178 
179  const_pointer address(const_reference x) const { return std::addressof(x); }
180 
184  void destroy(pointer p) {
185  // destroy using "explicit destructor"
186  p->~T();
187  }
188 
189  // Boilerplate
191  template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
192  template <typename U> struct rebind { using other = SecureAllocator<U>; };
193 };
194 
195 template <typename T, typename U>
197  return true;
198 }
199 
200 template <typename T, typename U>
202  return false;
203 }
204 
205 } // namespace Json
206 
207 #pragma pack(pop)
208 
209 #endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
210 
211 // //////////////////////////////////////////////////////////////////////
212 // End of content of file: include/json/allocator.h
213 // //////////////////////////////////////////////////////////////////////
214 
215 
216 
217 
218 
219 
220 // //////////////////////////////////////////////////////////////////////
221 // Beginning of content of file: include/json/config.h
222 // //////////////////////////////////////////////////////////////////////
223 
224 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
225 // Distributed under MIT license, or public domain if desired and
226 // recognized in your jurisdiction.
227 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
228 
229 #ifndef JSON_CONFIG_H_INCLUDED
230 #define JSON_CONFIG_H_INCLUDED
231 #include <cstddef>
232 #include <cstdint>
233 #include <istream>
234 #include <memory>
235 #include <ostream>
236 #include <sstream>
237 #include <string>
238 #include <type_traits>
239 
241 //# define JSON_IN_CPPTL 1
242 
244 //# define JSON_USE_CPPTL 1
248 //# define JSON_USE_CPPTL_SMALLMAP 1
249 
250 // If non-zero, the library uses exceptions to report bad input instead of C
251 // assertion macros. The default is to use exceptions.
252 #ifndef JSON_USE_EXCEPTION
253 #define JSON_USE_EXCEPTION 1
254 #endif
255 
259 // #define JSON_IS_AMALGAMATION
260 
261 #ifdef JSON_IN_CPPTL
262 #include <cpptl/config.h>
263 #ifndef JSON_USE_CPPTL
264 #define JSON_USE_CPPTL 1
265 #endif
266 #endif
267 
268 #ifdef JSON_IN_CPPTL
269 #define JSON_API CPPTL_API
270 #elif defined(JSON_DLL_BUILD)
271 #if defined(_MSC_VER) || defined(__MINGW32__)
272 #define JSON_API __declspec(dllexport)
273 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
274 #elif defined(__GNUC__) || defined(__clang__)
275 #define JSON_API __attribute__((visibility("default")))
276 #endif // if defined(_MSC_VER)
277 #elif defined(JSON_DLL)
278 #if defined(_MSC_VER) || defined(__MINGW32__)
279 #define JSON_API __declspec(dllimport)
280 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
281 #endif // if defined(_MSC_VER)
282 #endif // ifdef JSON_IN_CPPTL
283 #if !defined(JSON_API)
284 #define JSON_API
285 #endif
286 
287 #if defined(_MSC_VER) && _MSC_VER < 1800
288 #error \
289  "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
290 #endif
291 
292 #if defined(_MSC_VER) && _MSC_VER < 1900
293 // As recommended at
294 // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
295 extern JSON_API int
296 msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
297 #define jsoncpp_snprintf msvc_pre1900_c99_snprintf
298 #else
299 #define jsoncpp_snprintf std::snprintf
300 #endif
301 
302 // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
303 // integer
304 // Storages, and 64 bits integer support is disabled.
305 // #define JSON_NO_INT64 1
306 
307 // JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
308 // C++11 should be used directly in JSONCPP.
309 #define JSONCPP_OVERRIDE override
310 
311 #if __cplusplus >= 201103L
312 #define JSONCPP_NOEXCEPT noexcept
313 #define JSONCPP_OP_EXPLICIT explicit
314 #elif defined(_MSC_VER) && _MSC_VER < 1900
315 #define JSONCPP_NOEXCEPT throw()
316 #define JSONCPP_OP_EXPLICIT explicit
317 #elif defined(_MSC_VER) && _MSC_VER >= 1900
318 #define JSONCPP_NOEXCEPT noexcept
319 #define JSONCPP_OP_EXPLICIT explicit
320 #else
321 #define JSONCPP_NOEXCEPT throw()
322 #define JSONCPP_OP_EXPLICIT
323 #endif
324 
325 #ifdef __clang__
326 #if __has_extension(attribute_deprecated_with_message)
327 #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
328 #endif
329 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
330 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
331 #define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
332 #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
333 #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
334 #endif // GNUC version
335 #elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates MSVC)
336 #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
337 #endif // __clang__ || __GNUC__ || _MSC_VER
338 
339 #if !defined(JSONCPP_DEPRECATED)
340 #define JSONCPP_DEPRECATED(message)
341 #endif // if !defined(JSONCPP_DEPRECATED)
342 
343 #if __GNUC__ >= 6
344 #define JSON_USE_INT64_DOUBLE_CONVERSION 1
345 #endif
346 
347 #if !defined(JSON_IS_AMALGAMATION)
348 
349 #include "allocator.h"
350 #include "version.h"
351 
352 #endif // if !defined(JSON_IS_AMALGAMATION)
353 
354 namespace Json {
355 typedef int Int;
356 typedef unsigned int UInt;
357 #if defined(JSON_NO_INT64)
358 typedef int LargestInt;
359 typedef unsigned int LargestUInt;
360 #undef JSON_HAS_INT64
361 #else // if defined(JSON_NO_INT64)
362 // For Microsoft Visual use specific types as long long is not supported
363 #if defined(_MSC_VER) // Microsoft Visual Studio
364 typedef __int64 Int64;
365 typedef unsigned __int64 UInt64;
366 #else // if defined(_MSC_VER) // Other platforms, use long long
367 typedef int64_t Int64;
368 typedef uint64_t UInt64;
369 #endif // if defined(_MSC_VER)
370 typedef Int64 LargestInt;
371 typedef UInt64 LargestUInt;
372 #define JSON_HAS_INT64
373 #endif // if defined(JSON_NO_INT64)
374 
375 template <typename T>
376 using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
377  SecureAllocator<T>,
378  std::allocator<T>>::type;
379 using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
380 using IStringStream = std::basic_istringstream<String::value_type,
381  String::traits_type,
382  String::allocator_type>;
383 using OStringStream = std::basic_ostringstream<String::value_type,
384  String::traits_type,
385  String::allocator_type>;
386 using IStream = std::istream;
387 using OStream = std::ostream;
388 } // namespace Json
389 
390 // Legacy names (formerly macros).
396 
397 #endif // JSON_CONFIG_H_INCLUDED
398 
399 // //////////////////////////////////////////////////////////////////////
400 // End of content of file: include/json/config.h
401 // //////////////////////////////////////////////////////////////////////
402 
403 
404 
405 
406 
407 
408 // //////////////////////////////////////////////////////////////////////
409 // Beginning of content of file: include/json/forwards.h
410 // //////////////////////////////////////////////////////////////////////
411 
412 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
413 // Distributed under MIT license, or public domain if desired and
414 // recognized in your jurisdiction.
415 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
416 
417 #ifndef JSON_FORWARDS_H_INCLUDED
418 #define JSON_FORWARDS_H_INCLUDED
419 
420 #if !defined(JSON_IS_AMALGAMATION)
421 #include "config.h"
422 #endif // if !defined(JSON_IS_AMALGAMATION)
423 
424 namespace Json {
425 
426 // writer.h
427 class FastWriter;
428 class StyledWriter;
429 
430 // reader.h
431 class Reader;
432 
433 // features.h
434 class Features;
435 
436 // value.h
437 typedef unsigned int ArrayIndex;
438 class StaticString;
439 class Path;
440 class PathArgument;
441 class Value;
442 class ValueIteratorBase;
443 class ValueIterator;
444 class ValueConstIterator;
445 
446 } // namespace Json
447 
448 #endif // JSON_FORWARDS_H_INCLUDED
449 
450 // //////////////////////////////////////////////////////////////////////
451 // End of content of file: include/json/forwards.h
452 // //////////////////////////////////////////////////////////////////////
453 
454 
455 
456 
457 
458 
459 // //////////////////////////////////////////////////////////////////////
460 // Beginning of content of file: include/json/features.h
461 // //////////////////////////////////////////////////////////////////////
462 
463 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
464 // Distributed under MIT license, or public domain if desired and
465 // recognized in your jurisdiction.
466 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
467 
468 #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
469 #define CPPTL_JSON_FEATURES_H_INCLUDED
470 
471 #if !defined(JSON_IS_AMALGAMATION)
472 #include "forwards.h"
473 #endif // if !defined(JSON_IS_AMALGAMATION)
474 
475 #pragma pack(push, 8)
476 
477 namespace Json {
478 
484 public:
491  static Features all();
492 
499  static Features strictMode();
500 
503  Features();
504 
506  bool allowComments_{true};
507 
510  bool strictRoot_{false};
511 
513  bool allowDroppedNullPlaceholders_{false};
514 
516  bool allowNumericKeys_{false};
517 };
518 
519 } // namespace Json
520 
521 #pragma pack(pop)
522 
523 #endif // CPPTL_JSON_FEATURES_H_INCLUDED
524 
525 // //////////////////////////////////////////////////////////////////////
526 // End of content of file: include/json/features.h
527 // //////////////////////////////////////////////////////////////////////
528 
529 
530 
531 
532 
533 
534 // //////////////////////////////////////////////////////////////////////
535 // Beginning of content of file: include/json/value.h
536 // //////////////////////////////////////////////////////////////////////
537 
538 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
539 // Distributed under MIT license, or public domain if desired and
540 // recognized in your jurisdiction.
541 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
542 
543 #ifndef CPPTL_JSON_H_INCLUDED
544 #define CPPTL_JSON_H_INCLUDED
545 
546 #if !defined(JSON_IS_AMALGAMATION)
547 #include "forwards.h"
548 #endif // if !defined(JSON_IS_AMALGAMATION)
549 #include <array>
550 #include <exception>
551 #include <memory>
552 #include <string>
553 #include <vector>
554 
555 #ifndef JSON_USE_CPPTL_SMALLMAP
556 #include <map>
557 #else
558 #include <cpptl/smallmap.h>
559 #endif
560 #ifdef JSON_USE_CPPTL
561 #include <cpptl/forwards.h>
562 #endif
563 
564 // Conditional NORETURN attribute on the throw functions would:
565 // a) suppress false positives from static code analysis
566 // b) possibly improve optimization opportunities.
567 #if !defined(JSONCPP_NORETURN)
568 #if defined(_MSC_VER)
569 #define JSONCPP_NORETURN __declspec(noreturn)
570 #elif defined(__GNUC__)
571 #define JSONCPP_NORETURN __attribute__((__noreturn__))
572 #else
573 #define JSONCPP_NORETURN
574 #endif
575 #endif
576 
577 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
578 // be used by...
579 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
580 #pragma warning(push)
581 #pragma warning(disable : 4251)
582 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
583 
584 #pragma pack(push, 8)
585 
588 namespace Json {
589 
594 class JSON_API Exception : public std::exception {
595 public:
596  Exception(String msg);
597  ~Exception() JSONCPP_NOEXCEPT override;
598  char const* what() const JSONCPP_NOEXCEPT override;
599 
600 protected:
602 };
603 
611 public:
612  RuntimeError(String const& msg);
613 };
614 
621 class JSON_API LogicError : public Exception {
622 public:
623  LogicError(String const& msg);
624 };
625 
627 JSONCPP_NORETURN void throwRuntimeError(String const& msg);
629 JSONCPP_NORETURN void throwLogicError(String const& msg);
630 
633 enum ValueType {
634  nullValue = 0,
642 };
643 
650 };
651 
657 };
658 
659 //# ifdef JSON_USE_CPPTL
660 // typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
661 // typedef CppTL::AnyEnumerator<const Value &> EnumValues;
662 //# endif
663 
679 public:
680  explicit StaticString(const char* czstring) : c_str_(czstring) {}
681 
682  operator const char*() const { return c_str_; }
683 
684  const char* c_str() const { return c_str_; }
685 
686 private:
687  const char* c_str_;
688 };
689 
725  friend class ValueIteratorBase;
726 
727 public:
728  typedef std::vector<String> Members;
731  typedef Json::UInt UInt;
732  typedef Json::Int Int;
733 #if defined(JSON_HAS_INT64)
736 #endif // defined(JSON_HAS_INT64)
740 
741  // Required for boost integration, e. g. BOOST_TEST
742  typedef std::string value_type;
743 
744  static const Value& null;
745  static const Value& nullRef;
747  static Value const& nullSingleton();
749 
751  static const LargestInt minLargestInt;
753  static const LargestInt maxLargestInt;
755  static const LargestUInt maxLargestUInt;
756 
758  static const Int minInt;
760  static const Int maxInt;
762  static const UInt maxUInt;
763 
764 #if defined(JSON_HAS_INT64)
765  static const Int64 minInt64;
768  static const Int64 maxInt64;
770  static const UInt64 maxUInt64;
771 #endif // defined(JSON_HAS_INT64)
772 
774  static const UInt defaultRealPrecision;
775 
776 // Workaround for bug in the NVIDIAs CUDA 9.1 nvcc compiler
777 // when using gcc and clang backend compilers. CZString
778 // cannot be defined as private. See issue #486
779 #ifdef __NVCC__
780 public:
781 #else
782 private:
783 #endif
784 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
785  class CZString {
786  public:
787  enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
788  CZString(ArrayIndex index);
789  CZString(char const* str, unsigned length, DuplicationPolicy allocate);
790  CZString(CZString const& other);
791  CZString(CZString&& other);
792  ~CZString();
793  CZString& operator=(const CZString& other);
794  CZString& operator=(CZString&& other);
795 
796  bool operator<(CZString const& other) const;
797  bool operator==(CZString const& other) const;
798  ArrayIndex index() const;
799  // const char* c_str() const; ///< \deprecated
800  char const* data() const;
801  unsigned length() const;
802  bool isStaticString() const;
803 
804  private:
805  void swap(CZString& other);
806 
807  struct StringStorage {
808  unsigned policy_ : 2;
809  unsigned length_ : 30; // 1GB max
810  };
811 
812  char const* cstr_; // actually, a prefixed string, unless policy is noDup
813  union {
814  ArrayIndex index_;
815  StringStorage storage_;
816  };
817  };
818 
819 public:
820 #ifndef JSON_USE_CPPTL_SMALLMAP
821  typedef std::map<CZString, Value> ObjectValues;
822 #else
823  typedef CppTL::SmallMap<CZString, Value> ObjectValues;
824 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
825 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
826 
827 public:
843  Value(ValueType type = nullValue);
844  Value(Int value);
845  Value(UInt value);
846 #if defined(JSON_HAS_INT64)
847  Value(Int64 value);
848  Value(UInt64 value);
849 #endif // if defined(JSON_HAS_INT64)
850  Value(double value);
851  Value(const char* value);
852  Value(const char* begin, const char* end);
853 
868  Value(const StaticString& value);
869  Value(const String& value);
870 #ifdef JSON_USE_CPPTL
872  Value(const CppTL::ConstString& value);
873 #endif
874  Value(bool value);
875  Value(const Value& other);
876  Value(Value&& other);
877  ~Value();
878 
881  Value& operator=(const Value& other);
882  Value& operator=(Value&& other);
883 
885  void swap(Value& other);
887  void swapPayload(Value& other);
888 
890  void copy(const Value& other);
892  void copyPayload(const Value& other);
893 
894  ValueType type() const;
895 
897  bool operator<(const Value& other) const;
898  bool operator<=(const Value& other) const;
899  bool operator>=(const Value& other) const;
900  bool operator>(const Value& other) const;
901  bool operator==(const Value& other) const;
902  bool operator!=(const Value& other) const;
903  int compare(const Value& other) const;
904 
905  const char* asCString() const;
906 #if JSONCPP_USING_SECURE_MEMORY
907  unsigned getCStringLength() const; // Allows you to understand the length of
908  // the CString
909 #endif
910  String asString() const;
911 
914  bool getString(char const** begin, char const** end) const;
915 #ifdef JSON_USE_CPPTL
916  CppTL::ConstString asConstString() const;
917 #endif
918  Int asInt() const;
919  UInt asUInt() const;
920 #if defined(JSON_HAS_INT64)
921  Int64 asInt64() const;
922  UInt64 asUInt64() const;
923 #endif // if defined(JSON_HAS_INT64)
924  LargestInt asLargestInt() const;
925  LargestUInt asLargestUInt() const;
926  float asFloat() const;
927  double asDouble() const;
928  bool asBool() const;
929 
930  bool isNull() const;
931  bool isBool() const;
932  bool isInt() const;
933  bool isInt64() const;
934  bool isUInt() const;
935  bool isUInt64() const;
936  bool isIntegral() const;
937  bool isDouble() const;
938  bool isNumeric() const;
939  bool isString() const;
940  bool isArray() const;
941  bool isObject() const;
942 
943  bool isConvertibleTo(ValueType other) const;
944 
946  ArrayIndex size() const;
947 
950  bool empty() const;
951 
953  JSONCPP_OP_EXPLICIT operator bool() const;
954 
958  void clear();
959 
965  void resize(ArrayIndex newSize);
966 
973  Value& operator[](ArrayIndex index);
974 
981  Value& operator[](int index);
982 
986  const Value& operator[](ArrayIndex index) const;
987 
991  const Value& operator[](int index) const;
992 
996  Value get(ArrayIndex index, const Value& defaultValue) const;
998  bool isValidIndex(ArrayIndex index) const;
1002  Value& append(const Value& value);
1003  Value& append(Value&& value);
1004 
1008  Value& operator[](const char* key);
1011  const Value& operator[](const char* key) const;
1014  Value& operator[](const String& key);
1018  const Value& operator[](const String& key) const;
1032  Value& operator[](const StaticString& key);
1033 #ifdef JSON_USE_CPPTL
1034  Value& operator[](const CppTL::ConstString& key);
1038  const Value& operator[](const CppTL::ConstString& key) const;
1039 #endif
1040  Value get(const char* key, const Value& defaultValue) const;
1046  Value
1047  get(const char* begin, const char* end, const Value& defaultValue) const;
1051  Value get(const String& key, const Value& defaultValue) const;
1052 #ifdef JSON_USE_CPPTL
1053  Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
1056 #endif
1057  Value const* find(char const* begin, char const* end) const;
1064  Value* demand(char const* begin, char const* end);
1070  void removeMember(const char* key);
1073  void removeMember(const String& key);
1076  bool removeMember(const char* key, Value* removed);
1083  bool removeMember(String const& key, Value* removed);
1085  bool removeMember(const char* begin, const char* end, Value* removed);
1092  bool removeIndex(ArrayIndex index, Value* removed);
1093 
1096  bool isMember(const char* key) const;
1099  bool isMember(const String& key) const;
1101  bool isMember(const char* begin, const char* end) const;
1102 #ifdef JSON_USE_CPPTL
1103  bool isMember(const CppTL::ConstString& key) const;
1105 #endif
1106 
1112  Members getMemberNames() const;
1113 
1114  //# ifdef JSON_USE_CPPTL
1115  // EnumMemberNames enumMemberNames() const;
1116  // EnumValues enumValues() const;
1117  //# endif
1118 
1120  JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
1121  void setComment(const char* comment, CommentPlacement placement) {
1122  setComment(String(comment, strlen(comment)), placement);
1123  }
1125  void setComment(const char* comment, size_t len, CommentPlacement placement) {
1126  setComment(String(comment, len), placement);
1127  }
1129  void setComment(String comment, CommentPlacement placement);
1130  bool hasComment(CommentPlacement placement) const;
1132  String getComment(CommentPlacement placement) const;
1133 
1134  String toStyledString() const;
1135 
1136  const_iterator begin() const;
1137  const_iterator end() const;
1138 
1139  iterator begin();
1140  iterator end();
1141 
1142  // Accessors for the [start, limit) range of bytes within the JSON text from
1143  // which this value was parsed, if any.
1144  void setOffsetStart(ptrdiff_t start);
1145  void setOffsetLimit(ptrdiff_t limit);
1146  ptrdiff_t getOffsetStart() const;
1147  ptrdiff_t getOffsetLimit() const;
1148 
1149 private:
1150  void setType(ValueType v) { bits_.value_type_ = static_cast<unsigned char> (v); }
1151  bool isAllocated() const { return bits_.allocated_; }
1152  void setIsAllocated(bool v) { bits_.allocated_ = v; }
1153 
1154  void initBasic(ValueType type, bool allocated = false);
1155  void dupPayload(const Value& other);
1156  void releasePayload();
1157  void dupMeta(const Value& other);
1158 
1159  Value& resolveReference(const char* key);
1160  Value& resolveReference(const char* key, const char* end);
1161 
1162  // struct MemberNamesTransform
1163  //{
1164  // typedef const char *result_type;
1165  // const char *operator()( const CZString &name ) const
1166  // {
1167  // return name.c_str();
1168  // }
1169  //};
1170 
1171  union ValueHolder {
1172  LargestInt int_;
1173  LargestUInt uint_;
1174  double real_;
1175  bool bool_;
1176  char* string_; // if allocated_, ptr to { unsigned, char[] }.
1177  ObjectValues* map_;
1178  } value_;
1179 
1180  struct {
1181  // Really a ValueType, but types should agree for bitfield packing.
1182  unsigned int value_type_ : 8;
1183  // Unless allocated_, string_ must be null-terminated.
1184  unsigned int allocated_ : 1;
1185  } bits_;
1186 
1187  class Comments {
1188  public:
1189  Comments() = default;
1190  Comments(const Comments& that);
1191  Comments(Comments&& that);
1192  Comments& operator=(const Comments& that);
1193  Comments& operator=(Comments&& that);
1194  bool has(CommentPlacement slot) const;
1195  String get(CommentPlacement slot) const;
1196  void set(CommentPlacement slot, String s);
1197 
1198  private:
1199  using Array = std::array<String, numberOfCommentPlacement>;
1200  std::unique_ptr<Array> ptr_;
1201  };
1202  Comments comments_;
1203 
1204  // [start, limit) byte offsets in the source JSON text from which this Value
1205  // was extracted.
1206  ptrdiff_t start_;
1207  ptrdiff_t limit_;
1208 };
1209 
1214 public:
1215  friend class Path;
1216 
1217  PathArgument();
1218  PathArgument(ArrayIndex index);
1219  PathArgument(const char* key);
1220  PathArgument(const String& key);
1221 
1222 private:
1223  enum Kind { kindNone = 0, kindIndex, kindKey };
1224  String key_;
1225  ArrayIndex index_{};
1226  Kind kind_{kindNone};
1227 };
1228 
1241 public:
1242  Path(const String& path,
1243  const PathArgument& a1 = PathArgument(),
1244  const PathArgument& a2 = PathArgument(),
1245  const PathArgument& a3 = PathArgument(),
1246  const PathArgument& a4 = PathArgument(),
1247  const PathArgument& a5 = PathArgument());
1248 
1249  const Value& resolve(const Value& root) const;
1250  Value resolve(const Value& root, const Value& defaultValue) const;
1253  Value& make(Value& root) const;
1254 
1255 private:
1256  typedef std::vector<const PathArgument*> InArgs;
1257  typedef std::vector<PathArgument> Args;
1258 
1259  void makePath(const String& path, const InArgs& in);
1260  void addPathInArg(const String& path,
1261  const InArgs& in,
1262  InArgs::const_iterator& itInArg,
1263  PathArgument::Kind kind);
1264  static void invalidPath(const String& path, int location);
1265 
1266  Args args_;
1267 };
1268 
1273 public:
1274  typedef std::bidirectional_iterator_tag iterator_category;
1275  typedef unsigned int size_t;
1276  typedef int difference_type;
1278 
1279  bool operator==(const SelfType& other) const { return isEqual(other); }
1280 
1281  bool operator!=(const SelfType& other) const { return !isEqual(other); }
1282 
1283  difference_type operator-(const SelfType& other) const {
1284  return other.computeDistance(*this);
1285  }
1286 
1289  Value key() const;
1290 
1293  UInt index() const;
1294 
1298  String name() const;
1299 
1304  JSONCPP_DEPRECATED("Use `key = name();` instead.")
1305  char const* memberName() const;
1309  char const* memberName(char const** end) const;
1310 
1311 protected:
1312  Value& deref() const;
1313 
1314  void increment();
1315 
1316  void decrement();
1317 
1318  difference_type computeDistance(const SelfType& other) const;
1319 
1320  bool isEqual(const SelfType& other) const;
1321 
1322  void copy(const SelfType& other);
1323 
1324 private:
1325  Value::ObjectValues::iterator current_;
1326  // Indicates that iterator is for a null value.
1327  bool isNull_{true};
1328 
1329 public:
1330  // For some reason, BORLAND needs these at the end, rather
1331  // than earlier. No idea why.
1333  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
1334 };
1335 
1340  friend class Value;
1341 
1342 public:
1343  typedef const Value value_type;
1344  // typedef unsigned int size_t;
1345  // typedef int difference_type;
1346  typedef const Value& reference;
1347  typedef const Value* pointer;
1349 
1352 
1353 private:
1356  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
1357 
1358 public:
1359  SelfType& operator=(const ValueIteratorBase& other);
1360 
1361  SelfType operator++(int) {
1362  SelfType temp(*this);
1363  ++*this;
1364  return temp;
1365  }
1366 
1367  SelfType operator--(int) {
1368  SelfType temp(*this);
1369  --*this;
1370  return temp;
1371  }
1372 
1373  SelfType& operator--() {
1374  decrement();
1375  return *this;
1376  }
1377 
1378  SelfType& operator++() {
1379  increment();
1380  return *this;
1381  }
1382 
1383  reference operator*() const { return deref(); }
1384 
1385  pointer operator->() const { return &deref(); }
1386 };
1387 
1391  friend class Value;
1392 
1393 public:
1395  typedef unsigned int size_t;
1396  typedef int difference_type;
1397  typedef Value& reference;
1398  typedef Value* pointer;
1400 
1401  ValueIterator();
1402  explicit ValueIterator(const ValueConstIterator& other);
1404 
1405 private:
1408  explicit ValueIterator(const Value::ObjectValues::iterator& current);
1409 
1410 public:
1411  SelfType& operator=(const SelfType& other);
1412 
1413  SelfType operator++(int) {
1414  SelfType temp(*this);
1415  ++*this;
1416  return temp;
1417  }
1418 
1419  SelfType operator--(int) {
1420  SelfType temp(*this);
1421  --*this;
1422  return temp;
1423  }
1424 
1425  SelfType& operator--() {
1426  decrement();
1427  return *this;
1428  }
1429 
1430  SelfType& operator++() {
1431  increment();
1432  return *this;
1433  }
1434 
1435  reference operator*() const { return deref(); }
1436 
1437  pointer operator->() const { return &deref(); }
1438 };
1439 
1440 inline void swap(Value& a, Value& b) { a.swap(b); }
1441 
1442 } // namespace Json
1443 
1444 #pragma pack(pop)
1445 
1446 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1447 #pragma warning(pop)
1448 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1449 
1450 #endif // CPPTL_JSON_H_INCLUDED
1451 
1452 // //////////////////////////////////////////////////////////////////////
1453 // End of content of file: include/json/value.h
1454 // //////////////////////////////////////////////////////////////////////
1455 
1456 
1457 
1458 
1459 
1460 
1461 // //////////////////////////////////////////////////////////////////////
1462 // Beginning of content of file: include/json/reader.h
1463 // //////////////////////////////////////////////////////////////////////
1464 
1465 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
1466 // Distributed under MIT license, or public domain if desired and
1467 // recognized in your jurisdiction.
1468 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1469 
1470 #ifndef CPPTL_JSON_READER_H_INCLUDED
1471 #define CPPTL_JSON_READER_H_INCLUDED
1472 
1473 #if !defined(JSON_IS_AMALGAMATION)
1474 #include "features.h"
1475 #include "value.h"
1476 #endif // if !defined(JSON_IS_AMALGAMATION)
1477 #include <deque>
1478 #include <iosfwd>
1479 #include <istream>
1480 #include <stack>
1481 #include <string>
1482 
1483 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
1484 // be used by...
1485 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1486 #pragma warning(push)
1487 #pragma warning(disable : 4251)
1488 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1489 
1490 #pragma pack(push, 8)
1491 
1492 namespace Json {
1493 
1500 public:
1501  typedef char Char;
1502  typedef const Char* Location;
1503 
1511  ptrdiff_t offset_start;
1512  ptrdiff_t offset_limit;
1514  };
1515 
1519  JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
1520  Reader();
1521 
1526  Reader(const Features& features);
1527 
1542  bool
1543  parse(const std::string& document, Value& root, bool collectComments = true);
1544 
1563  bool parse(const char* beginDoc,
1564  const char* endDoc,
1565  Value& root,
1566  bool collectComments = true);
1567 
1570  bool parse(IStream& is, Value& root, bool collectComments = true);
1571 
1581  JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
1582  String getFormatedErrorMessages() const;
1583 
1592  String getFormattedErrorMessages() const;
1593 
1601  std::vector<StructuredError> getStructuredErrors() const;
1602 
1609  bool pushError(const Value& value, const String& message);
1610 
1618  bool pushError(const Value& value, const String& message, const Value& extra);
1619 
1624  bool good() const;
1625 
1626 private:
1627  enum TokenType {
1628  tokenEndOfStream = 0,
1629  tokenObjectBegin,
1630  tokenObjectEnd,
1631  tokenArrayBegin,
1632  tokenArrayEnd,
1633  tokenString,
1634  tokenNumber,
1635  tokenTrue,
1636  tokenFalse,
1637  tokenNull,
1638  tokenArraySeparator,
1639  tokenMemberSeparator,
1640  tokenComment,
1641  tokenError
1642  };
1643 
1644  class Token {
1645  public:
1646  TokenType type_;
1647  Location start_;
1648  Location end_;
1649  };
1650 
1651  class ErrorInfo {
1652  public:
1653  Token token_;
1654  String message_;
1655  Location extra_;
1656  };
1657 
1658  typedef std::deque<ErrorInfo> Errors;
1659 
1660  bool readToken(Token& token);
1661  void skipSpaces();
1662  bool match(Location pattern, int patternLength);
1663  bool readComment();
1664  bool readCStyleComment();
1665  bool readCppStyleComment();
1666  bool readString();
1667  void readNumber();
1668  bool readValue();
1669  bool readObject(Token& token);
1670  bool readArray(Token& token);
1671  bool decodeNumber(Token& token);
1672  bool decodeNumber(Token& token, Value& decoded);
1673  bool decodeString(Token& token);
1674  bool decodeString(Token& token, String& decoded);
1675  bool decodeDouble(Token& token);
1676  bool decodeDouble(Token& token, Value& decoded);
1677  bool decodeUnicodeCodePoint(Token& token,
1678  Location& current,
1679  Location end,
1680  unsigned int& unicode);
1681  bool decodeUnicodeEscapeSequence(Token& token,
1682  Location& current,
1683  Location end,
1684  unsigned int& unicode);
1685  bool addError(const String& message, Token& token, Location extra = nullptr);
1686  bool recoverFromError(TokenType skipUntilToken);
1687  bool addErrorAndRecover(const String& message,
1688  Token& token,
1689  TokenType skipUntilToken);
1690  void skipUntilSpace();
1691  Value& currentValue();
1692  Char getNextChar();
1693  void
1694  getLocationLineAndColumn(Location location, int& line, int& column) const;
1695  String getLocationLineAndColumn(Location location) const;
1696  void addComment(Location begin, Location end, CommentPlacement placement);
1697  void skipCommentTokens(Token& token);
1698 
1699  static bool containsNewLine(Location begin, Location end);
1700  static String normalizeEOL(Location begin, Location end);
1701 
1702  typedef std::stack<Value*> Nodes;
1703  Nodes nodes_;
1704  Errors errors_;
1705  String document_;
1706  Location begin_{};
1707  Location end_{};
1708  Location current_{};
1709  Location lastValueEnd_{};
1710  Value* lastValue_{};
1711  String commentsBefore_;
1712  Features features_;
1713  bool collectComments_{};
1714 }; // Reader
1715 
1719 public:
1720  virtual ~CharReader() = default;
1739  virtual bool parse(char const* beginDoc,
1740  char const* endDoc,
1741  Value* root,
1742  String* errs) = 0;
1743 
1745  public:
1746  virtual ~Factory() = default;
1750  virtual CharReader* newCharReader() const = 0;
1751  }; // Factory
1752 }; // CharReader
1753 
1767 public:
1768  // Note: We use a Json::Value so that we can add data-members to this class
1769  // without a major version bump.
1809 
1811  ~CharReaderBuilder() override;
1812 
1813  CharReader* newCharReader() const override;
1814 
1818  bool validate(Json::Value* invalid) const;
1819 
1822  Value& operator[](const String& key);
1823 
1829  static void setDefaults(Json::Value* settings);
1835  static void strictMode(Json::Value* settings);
1836 };
1837 
1843  IStream&,
1844  Value* root,
1845  std::string* errs);
1846 
1872 
1873 } // namespace Json
1874 
1875 #pragma pack(pop)
1876 
1877 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1878 #pragma warning(pop)
1879 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1880 
1881 #endif // CPPTL_JSON_READER_H_INCLUDED
1882 
1883 // //////////////////////////////////////////////////////////////////////
1884 // End of content of file: include/json/reader.h
1885 // //////////////////////////////////////////////////////////////////////
1886 
1887 
1888 
1889 
1890 
1891 
1892 // //////////////////////////////////////////////////////////////////////
1893 // Beginning of content of file: include/json/writer.h
1894 // //////////////////////////////////////////////////////////////////////
1895 
1896 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
1897 // Distributed under MIT license, or public domain if desired and
1898 // recognized in your jurisdiction.
1899 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1900 
1901 #ifndef JSON_WRITER_H_INCLUDED
1902 #define JSON_WRITER_H_INCLUDED
1903 
1904 #if !defined(JSON_IS_AMALGAMATION)
1905 #include "value.h"
1906 #endif // if !defined(JSON_IS_AMALGAMATION)
1907 #include <ostream>
1908 #include <string>
1909 #include <vector>
1910 
1911 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
1912 // be used by...
1913 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
1914 #pragma warning(push)
1915 #pragma warning(disable : 4251)
1916 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1917 
1918 #pragma pack(push, 8)
1919 
1920 namespace Json {
1921 
1922 class Value;
1923 
1938 protected:
1939  OStream* sout_; // not owned; will not delete
1940 public:
1941  StreamWriter();
1942  virtual ~StreamWriter();
1949  virtual int write(Value const& root, OStream* sout) = 0;
1950 
1954  public:
1955  virtual ~Factory();
1959  virtual StreamWriter* newStreamWriter() const = 0;
1960  }; // Factory
1961 }; // StreamWriter
1962 
1967  Value const& root);
1968 
1985 public:
1986  // Note: We use a Json::Value so that we can add data-members to this class
1987  // without a major version bump.
2015 
2017  ~StreamWriterBuilder() override;
2018 
2022  StreamWriter* newStreamWriter() const override;
2023 
2027  bool validate(Json::Value* invalid) const;
2030  Value& operator[](const String& key);
2031 
2037  static void setDefaults(Json::Value* settings);
2038 };
2039 
2044 public:
2045  virtual ~Writer();
2046 
2047  virtual String write(const Value& root) = 0;
2048 };
2049 
2059 #if defined(_MSC_VER)
2060 #pragma warning(push)
2061 #pragma warning(disable : 4996) // Deriving from deprecated class
2062 #endif
2064  : public Writer {
2065 public:
2066  FastWriter();
2067  ~FastWriter() override = default;
2068 
2069  void enableYAMLCompatibility();
2070 
2076  void dropNullPlaceholders();
2077 
2078  void omitEndingLineFeed();
2079 
2080 public: // overridden from Writer
2081  String write(const Value& root) override;
2082 
2083 private:
2084  void writeValue(const Value& value);
2085 
2086  String document_;
2087  bool yamlCompatibilityEnabled_{false};
2088  bool dropNullPlaceholders_{false};
2089  bool omitEndingLineFeed_{false};
2090 };
2091 #if defined(_MSC_VER)
2092 #pragma warning(pop)
2093 #endif
2094 
2119 #if defined(_MSC_VER)
2120 #pragma warning(push)
2121 #pragma warning(disable : 4996) // Deriving from deprecated class
2122 #endif
2124  StyledWriter : public Writer {
2125 public:
2126  StyledWriter();
2127  ~StyledWriter() override = default;
2128 
2129 public: // overridden from Writer
2134  String write(const Value& root) override;
2135 
2136 private:
2137  void writeValue(const Value& value);
2138  void writeArrayValue(const Value& value);
2139  bool isMultilineArray(const Value& value);
2140  void pushValue(const String& value);
2141  void writeIndent();
2142  void writeWithIndent(const String& value);
2143  void indent();
2144  void unindent();
2145  void writeCommentBeforeValue(const Value& root);
2146  void writeCommentAfterValueOnSameLine(const Value& root);
2147  static bool hasCommentForValue(const Value& value);
2148  static String normalizeEOL(const String& text);
2149 
2150  typedef std::vector<String> ChildValues;
2151 
2152  ChildValues childValues_;
2153  String document_;
2154  String indentString_;
2155  unsigned int rightMargin_{74};
2156  unsigned int indentSize_{3};
2157  bool addChildValues_{false};
2158 };
2159 #if defined(_MSC_VER)
2160 #pragma warning(pop)
2161 #endif
2162 
2188 #if defined(_MSC_VER)
2189 #pragma warning(push)
2190 #pragma warning(disable : 4996) // Deriving from deprecated class
2191 #endif
2194 public:
2198  StyledStreamWriter(String indentation = "\t");
2199  ~StyledStreamWriter() = default;
2200 
2201 public:
2208  void write(OStream& out, const Value& root);
2209 
2210 private:
2211  void writeValue(const Value& value);
2212  void writeArrayValue(const Value& value);
2213  bool isMultilineArray(const Value& value);
2214  void pushValue(const String& value);
2215  void writeIndent();
2216  void writeWithIndent(const String& value);
2217  void indent();
2218  void unindent();
2219  void writeCommentBeforeValue(const Value& root);
2220  void writeCommentAfterValueOnSameLine(const Value& root);
2221  static bool hasCommentForValue(const Value& value);
2222  static String normalizeEOL(const String& text);
2223 
2224  typedef std::vector<String> ChildValues;
2225 
2226  ChildValues childValues_;
2227  OStream* document_;
2228  String indentString_;
2229  unsigned int rightMargin_{74};
2230  String indentation_;
2231  bool addChildValues_ : 1;
2232  bool indented_ : 1;
2233 };
2234 #if defined(_MSC_VER)
2235 #pragma warning(pop)
2236 #endif
2237 
2238 #if defined(JSON_HAS_INT64)
2241 #endif // if defined(JSON_HAS_INT64)
2245 valueToString(double value,
2246  unsigned int precision = Value::defaultRealPrecision,
2248 String JSON_API valueToString(bool value);
2249 String JSON_API valueToQuotedString(const char* value);
2250 
2253 JSON_API OStream& operator<<(OStream&, const Value& root);
2254 
2255 } // namespace Json
2256 
2257 #pragma pack(pop)
2258 
2259 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2260 #pragma warning(pop)
2261 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2262 
2263 #endif // JSON_WRITER_H_INCLUDED
2264 
2265 // //////////////////////////////////////////////////////////////////////
2266 // End of content of file: include/json/writer.h
2267 // //////////////////////////////////////////////////////////////////////
2268 
2269 
2270 
2271 
2272 
2273 
2274 // //////////////////////////////////////////////////////////////////////
2275 // Beginning of content of file: include/json/assertions.h
2276 // //////////////////////////////////////////////////////////////////////
2277 
2278 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
2279 // Distributed under MIT license, or public domain if desired and
2280 // recognized in your jurisdiction.
2281 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2282 
2283 #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
2284 #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
2285 
2286 #include <cstdlib>
2287 #include <sstream>
2288 
2289 #if !defined(JSON_IS_AMALGAMATION)
2290 #include "config.h"
2291 #endif // if !defined(JSON_IS_AMALGAMATION)
2292 
2297 #if JSON_USE_EXCEPTION
2298 
2299 // @todo <= add detail about condition in exception
2300 #define JSON_ASSERT(condition) \
2301  { \
2302  if (!(condition)) { \
2303  Json::throwLogicError("assert json failed"); \
2304  } \
2305  }
2306 
2307 #define JSON_FAIL_MESSAGE(message) \
2308  { \
2309  OStringStream oss; \
2310  oss << message; \
2311  Json::throwLogicError(oss.str()); \
2312  abort(); \
2313  }
2314 
2315 #else // JSON_USE_EXCEPTION
2316 
2317 #define JSON_ASSERT(condition) assert(condition)
2318 
2319 // The call to assert() will show the failure message in debug builds. In
2320 // release builds we abort, for a core-dump or debugger.
2321 #define JSON_FAIL_MESSAGE(message) \
2322  { \
2323  OStringStream oss; \
2324  oss << message; \
2325  assert(false && oss.str().c_str()); \
2326  abort(); \
2327  }
2328 
2329 #endif
2330 
2331 #define JSON_ASSERT_MESSAGE(condition, message) \
2332  if (!(condition)) { \
2333  JSON_FAIL_MESSAGE(message); \
2334  }
2335 
2336 #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
2337 
2338 // //////////////////////////////////////////////////////////////////////
2339 // End of content of file: include/json/assertions.h
2340 // //////////////////////////////////////////////////////////////////////
2341 
2342 
2343 
2344 
2345 
2346 #endif //ifndef JSON_AMALGAMATED_H_INCLUDED
Definition: json.h:1744
void construct(pointer p, Args &&...args)
Definition: json.h:170
String msg_
Definition: json.h:601
T * pointer
Definition: json.h:139
unsigned int UInt
Definition: json-forwards.h:218
unsigned integer value
Definition: json.h:636
double value
Definition: json.h:637
Json::Value settings_
Definition: json.h:1808
static const Value & null
Definition: json.h:744
#define JSONCPP_NORETURN
Definition: json.h:573
ValueIterator iterator
Definition: json.h:729
int difference_type
Definition: json.h:1276
SelfType operator--(int)
Definition: json.h:1367
#define JSON_API
Definition: json.h:284
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
Definition: json.h:2192
pointer allocate(size_type n)
Definition: json.h:149
Json::LargestInt LargestInt
Definition: json.h:737
signed integer value
Definition: json.h:635
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition: json.h:755
ptrdiff_t offset_start
Definition: json.h:1511
char Char
Definition: json.h:1501
UInt64 LargestUInt
Definition: json-forwards.h:233
pointer operator->() const
Definition: json.h:1437
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
Definition: json.h:751
Json::IStream JSONCPP_ISTREAM
Definition: json-forwards.h:256
void destroy(pointer p)
Definition: json.h:184
Json::Int Int
Definition: json.h:732
Experimental and untested: represents an element of the "path" to access a node.
Definition: json.h:1213
Json::ArrayIndex ArrayIndex
Definition: json.h:739
SelfType & operator++()
Definition: json.h:1378
bool parseFromStream(CharReader::Factory const &, IStream &, Value *root, std::string *errs)
Lightweight wrapper to tag static string.
Definition: json.h:678
ValueConstIterator const_iterator
Definition: json.h:730
const T & const_reference
Definition: json.h:142
unsigned int ArrayIndex
Definition: json-forwards.h:296
STL namespace.
const Value & reference
Definition: json.h:1346
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition: json.h:762
Represents a JSON value.
Definition: json.h:724
Json::Int64 Int64
Definition: json.h:735
std::basic_istringstream< String::value_type, String::traits_type, String::allocator_type > IStringStream
Definition: json-forwards.h:244
const char * c_str() const
Definition: json.h:684
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition: json.h:483
Json::Value settings_
Definition: json.h:2014
const_pointer address(const_reference x) const
Definition: json.h:179
a comment placed on the line before a value
Definition: json.h:645
String writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience. A StreamWriter will be created from the...
Definition: jsoncpp.cpp:5383
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition: json.h:770
Definition: json.h:1937
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition: json.h:768
difference_type operator-(const SelfType &other) const
Definition: json.h:1283
Outputs a Value in JSON format without formatting (not human friendly).
Definition: json.h:2063
Json::IStringStream JSONCPP_ISTRINGSTREAM
Definition: json-forwards.h:254
SelfType & operator--()
Definition: json.h:1425
int difference_type
Definition: json.h:1396
void throwRuntimeError(String const &msg)
used internally
Definition: jsoncpp.cpp:2663
Definition: json.h:621
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition: json.h:758
#define JSONCPP_USING_SECURE_MEMORY
Definition: json.h:102
reference operator*() const
Definition: json.h:1435
Int64 LargestInt
Definition: json-forwards.h:232
Definition: json.h:594
difference_type computeDistance(const SelfType &other) const
Definition: jsoncpp.cpp:2287
std::map< CZString, Value > ObjectValues
Definition: json.h:821
PrecisionType
Type of precision for formatting of real values.
Definition: json.h:654
An error tagged with where in the JSON text it was encountered.
Definition: json.h:1510
Abstract class for writers.
Definition: json.h:2043
Json::OStringStream JSONCPP_OSTRINGSTREAM
Definition: json-forwards.h:255
ValueConstIterator SelfType
Definition: json.h:1348
Json::UInt UInt
Definition: json.h:731
String valueToQuotedString(const char *value)
Definition: jsoncpp.cpp:4483
object value (collection of name/value pairs).
Definition: json.h:641
bool value
Definition: json.h:639
Json::LargestUInt LargestUInt
Definition: json.h:738
Build a CharReader implementation.
Definition: json.h:1766
SelfType operator--(int)
Definition: json.h:1419
const T * const_pointer
Definition: json.h:140
void swap(Value &other)
Swap everything.
Definition: jsoncpp.cpp:2920
ValueType
Type of the value held by a Value object.
Definition: json.h:633
Definition: json.h:192
static const UInt defaultRealPrecision
Default precision for real value for string representation.
Definition: json.h:774
T & reference
Definition: json.h:141
root value)
Definition: json.h:649
void deallocate(volatile pointer p, size_type n)
Definition: json.h:161
JSON (JavaScript Object Notation).
Definition: json-forwards.h:216
ValueIteratorBase SelfType
Definition: json.h:1277
a comment just after a value on the same line
Definition: json.h:646
SecureAllocator< U > other
Definition: json.h:192
we set max number of digits after "." in string
Definition: json.h:656
Json::UInt64 UInt64
Definition: json.h:734
SelfType & operator++()
Definition: json.h:1430
base class for Value iterators.
Definition: json.h:1272
Value value_type
Definition: json.h:1394
bool operator==(const SelfType &other) const
Definition: json.h:1279
std::string value_type
Definition: json.h:742
CommentPlacement
Definition: json.h:644
void swap(Value &a, Value &b)
Definition: json.h:1440
typename std::conditional< JSONCPP_USING_SECURE_MEMORY, SecureAllocator< T >, std::allocator< T >>::type Allocator
Definition: json-forwards.h:240
const Value value_type
Definition: json.h:1343
std::size_t size_type
Definition: json.h:143
Definition: json.h:610
int Int
Definition: json-forwards.h:217
IStream & operator>>(IStream &, Value &)
Read from &#39;sin&#39; into &#39;root&#39;.
Definition: jsoncpp.cpp:2232
Definition: json.h:647
Value * pointer
Definition: json.h:1398
Json::String JSONCPP_STRING
Definition: json-forwards.h:253
&#39;null&#39; value
Definition: json.h:634
std::ostream OStream
Definition: json-forwards.h:249
pointer operator->() const
Definition: json.h:1385
ptrdiff_t offset_limit
Definition: json.h:1512
bool operator!=(const SelfType &other) const
Definition: json.h:1281
bool operator!=(const SecureAllocator< T > &, const SecureAllocator< U > &)
Definition: json.h:201
SelfType & operator--()
Definition: json.h:1373
pointer address(reference x) const
Definition: json.h:177
OStream * sout_
Definition: json.h:1939
UTF-8 string value.
Definition: json.h:638
SelfType operator++(int)
Definition: json.h:1413
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition: json.h:760
#define JSONCPP_NOEXCEPT
Definition: json.h:321
String valueToString(Int value)
unsigned int size_t
Definition: json.h:1275
A simple abstract factory.
Definition: json.h:1953
StaticString(const char *czstring)
Definition: json.h:680
std::istream IStream
Definition: json-forwards.h:248
Unserialize a JSON document into a Value.
Definition: json.h:1499
SelfType operator++(int)
Definition: json.h:1361
std::basic_ostringstream< String::value_type, String::traits_type, String::allocator_type > OStringStream
Definition: json-forwards.h:247
uint64_t UInt64
Definition: json-forwards.h:230
std::basic_string< char, std::char_traits< char >, Allocator< char >> String
Definition: json-forwards.h:241
void throwLogicError(String const &msg)
used internally
Definition: jsoncpp.cpp:2666
T value_type
Definition: json.h:138
String message
Definition: json.h:1513
ValueIterator SelfType
Definition: json.h:1399
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition: json.h:753
OStream & operator<<(OStream &, const Value &root)
Output using the StyledStreamWriter.
Definition: jsoncpp.cpp:5390
std::bidirectional_iterator_tag iterator_category
Definition: json.h:1274
Build a StreamWriter implementation.
Definition: json.h:1984
Iterator for object and array value.
Definition: json.h:1390
Json::OStream JSONCPP_OSTREAM
Definition: json-forwards.h:257
const Char * Location
Definition: json.h:1502
reference operator*() const
Definition: json.h:1383
we set max number of significant digits in string
Definition: json.h:655
std::vector< String > Members
Definition: json.h:728
Writes a Value in JSON format in a human friendly way.
Definition: json.h:2123
std::ptrdiff_t difference_type
Definition: json.h:144
Experimental and untested: represents a "path" to access a node.
Definition: json.h:1240
SecureAllocator()
Definition: json.h:190
Definition: json.h:1718
Definition: json.h:135
size_type max_size() const
Definition: json.h:175
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
Definition: json.h:1125
const iterator for object and array value.
Definition: json.h:1339
#define JSONCPP_OP_EXPLICIT
Definition: json.h:322
const Value * pointer
Definition: json.h:1347
#define JSONCPP_DEPRECATED(message)
Definition: json.h:340
unsigned int size_t
Definition: json.h:1395
array value (ordered list)
Definition: json.h:640
int64_t Int64
Definition: json-forwards.h:229
bool operator==(const SecureAllocator< T > &, const SecureAllocator< U > &)
Definition: json.h:196
Value & reference
Definition: json.h:1397
SecureAllocator(const SecureAllocator< U > &)
Definition: json.h:191