Mēnsūra
json.hpp
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 The author (Baptiste Lepilleur) explicitly disclaims 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 is
19 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
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_AMALGATED_H_INCLUDED
76 # define JSON_AMALGATED_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.7.2"
91 # define JSONCPP_VERSION_MAJOR 1
92 # define JSONCPP_VERSION_MINOR 7
93 # define JSONCPP_VERSION_PATCH 2
94 # define JSONCPP_VERSION_QUALIFIER
95 # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
96 
97 #ifdef JSONCPP_USING_SECURE_MEMORY
98 #undef JSONCPP_USING_SECURE_MEMORY
99 #endif
100 #define JSONCPP_USING_SECURE_MEMORY 0
101 // If non-zero, the library zeroes any memory that it has allocated before
102 // it frees its memory.
103 
104 #endif // JSON_VERSION_H_INCLUDED
105 
106 // //////////////////////////////////////////////////////////////////////
107 // End of content of file: include/json/version.h
108 // //////////////////////////////////////////////////////////////////////
109 
110 
111 
112 
113 
114 
115 // //////////////////////////////////////////////////////////////////////
116 // Beginning of content of file: include/json/allocator.h
117 // //////////////////////////////////////////////////////////////////////
118 
119 // Copyright 2007-2010 Baptiste Lepilleur
120 // Distributed under MIT license, or public domain if desired and
121 // recognized in your jurisdiction.
122 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
123 
124 #ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
125 #define CPPTL_JSON_ALLOCATOR_H_INCLUDED
126 
127 #include <cstring>
128 #include <memory>
129 
130 namespace Json {
131 template<typename T>
133  public:
134  // Type definitions
135  using value_type = T;
136  using pointer = T*;
137  using const_pointer = const T*;
138  using reference = T&;
139  using const_reference = const T&;
140  using size_type = std::size_t;
141  using difference_type = std::ptrdiff_t;
142 
146  pointer allocate(size_type n) {
147  // allocate using "global operator new"
148  return static_cast<pointer>(::operator new(n * sizeof(T)));
149  }
150 
158  void deallocate(volatile pointer p, size_type n) {
159  std::memset(p, 0, n * sizeof(T));
160  // free using "global operator delete"
161  ::operator delete(p);
162  }
163 
167  template<typename... Args>
168  void construct(pointer p, Args&&... args) {
169  // construct using "placement new" and "perfect forwarding"
170  ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
171  }
172 
173  size_type max_size() const {
174  return size_t(-1) / sizeof(T);
175  }
176 
177  pointer address( reference x ) const {
178  return std::addressof(x);
179  }
180 
181  const_pointer address( const_reference x ) const {
182  return std::addressof(x);
183  }
184 
188  void destroy(pointer p) {
189  // destroy using "explicit destructor"
190  p->~T();
191  }
192 
193  // Boilerplate
194  SecureAllocator() {}
195  template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
196  template<typename U> struct rebind { using other = SecureAllocator<U>; };
197 };
198 
199 
200 template<typename T, typename U>
201 bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
202  return true;
203 }
204 
205 template<typename T, typename U>
206 bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
207  return false;
208 }
209 
210 } //namespace Json
211 
212 #endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
213 
214 // //////////////////////////////////////////////////////////////////////
215 // End of content of file: include/json/allocator.h
216 // //////////////////////////////////////////////////////////////////////
217 
218 
219 
220 
221 
222 
223 // //////////////////////////////////////////////////////////////////////
224 // Beginning of content of file: include/json/config.h
225 // //////////////////////////////////////////////////////////////////////
226 
227 // Copyright 2007-2010 Baptiste Lepilleur
228 // Distributed under MIT license, or public domain if desired and
229 // recognized in your jurisdiction.
230 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
231 
232 #ifndef JSON_CONFIG_H_INCLUDED
233 #define JSON_CONFIG_H_INCLUDED
234 #include <stddef.h>
235 #include <string> //typdef String
236 
238 //# define JSON_IN_CPPTL 1
239 
241 //# define JSON_USE_CPPTL 1
245 //# define JSON_USE_CPPTL_SMALLMAP 1
246 
247 // If non-zero, the library uses exceptions to report bad input instead of C
248 // assertion macros. The default is to use exceptions.
249 #ifndef JSON_USE_EXCEPTION
250 #define JSON_USE_EXCEPTION 1
251 #endif
252 
256 // #define JSON_IS_AMALGAMATION
257 
258 #ifdef JSON_IN_CPPTL
259 #include <cpptl/config.h>
260 #ifndef JSON_USE_CPPTL
261 #define JSON_USE_CPPTL 1
262 #endif
263 #endif
264 
265 #ifdef JSON_IN_CPPTL
266 #define JSON_API CPPTL_API
267 #elif defined(JSON_DLL_BUILD)
268 #if defined(_MSC_VER) || defined(__MINGW32__)
269 #define JSON_API __declspec(dllexport)
270 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
271 #endif // if defined(_MSC_VER)
272 #elif defined(JSON_DLL)
273 #if defined(_MSC_VER) || defined(__MINGW32__)
274 #define JSON_API __declspec(dllimport)
275 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
276 #endif // if defined(_MSC_VER)
277 #endif // ifdef JSON_IN_CPPTL
278 #if !defined(JSON_API)
279 #define JSON_API
280 #endif
281 
282 // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
283 // integer
284 // Storages, and 64 bits integer support is disabled.
285 // #define JSON_NO_INT64 1
286 
287 #if defined(_MSC_VER) // MSVC
288 # if _MSC_VER <= 1200 // MSVC 6
289  // Microsoft Visual Studio 6 only support conversion from __int64 to double
290  // (no conversion from unsigned __int64).
291 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
292  // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
293  // characters in the debug information)
294  // All projects I've ever seen with VS6 were using this globally (not bothering
295  // with pragma push/pop).
296 # pragma warning(disable : 4786)
297 # endif // MSVC 6
298 
299 # if _MSC_VER >= 1500 // MSVC 2008
300 # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
302 # endif
303 
304 #endif // defined(_MSC_VER)
305 
306 #if defined(_MSC_VER) && _MSC_VER <= 1600 // MSVC <= 2010
307 # define JSONCPP_OVERRIDE
308 #else
309 # define JSONCPP_OVERRIDE override
310 #endif // MSVC <= 2010
311 
312 
313 #ifndef JSON_HAS_RVALUE_REFERENCES
314 
315 #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
316 #define JSON_HAS_RVALUE_REFERENCES 1
317 #endif // MSVC >= 2010
318 
319 #ifdef __clang__
320 #if __has_feature(cxx_rvalue_references)
321 #define JSON_HAS_RVALUE_REFERENCES 1
322 #endif // has_feature
323 
324 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
325 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
326 #define JSON_HAS_RVALUE_REFERENCES 1
327 #endif // GXX_EXPERIMENTAL
328 
329 #endif // __clang__ || __GNUC__
330 
331 #endif // not defined JSON_HAS_RVALUE_REFERENCES
332 
333 #ifndef JSON_HAS_RVALUE_REFERENCES
334 #define JSON_HAS_RVALUE_REFERENCES 0
335 #endif
336 
337 #ifdef __clang__
338 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
339 # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
340 # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
341 # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
342 # define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
343 # endif // GNUC version
344 #endif // __clang__ || __GNUC__
345 
346 #if !defined(JSONCPP_DEPRECATED)
347 #define JSONCPP_DEPRECATED(message)
348 #endif // if !defined(JSONCPP_DEPRECATED)
349 
350 #if __GNUC__ >= 6
351 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
352 #endif
353 
354 #if !defined(JSON_IS_AMALGAMATION)
355 
356 # include "version.h"
357 
358 # if JSONCPP_USING_SECURE_MEMORY
359 # include "allocator.h" //typedef Allocator
360 # endif
361 
362 #endif // if !defined(JSON_IS_AMALGAMATION)
363 
364 namespace Json {
365 typedef int Int;
366 typedef unsigned int UInt;
367 #if defined(JSON_NO_INT64)
368 typedef int LargestInt;
369 typedef unsigned int LargestUInt;
370 #undef JSON_HAS_INT64
371 #else // if defined(JSON_NO_INT64)
372 // For Microsoft Visual use specific types as long long is not supported
373 #if defined(_MSC_VER) // Microsoft Visual Studio
374 typedef __int64 Int64;
375 typedef unsigned __int64 UInt64;
376 #else // if defined(_MSC_VER) // Other platforms, use long long
377 typedef long long int Int64;
378 typedef unsigned long long int UInt64;
379 #endif // if defined(_MSC_VER)
380 typedef Int64 LargestInt;
381 typedef UInt64 LargestUInt;
382 #define JSON_HAS_INT64
383 #endif // if defined(JSON_NO_INT64)
384 #if JSONCPP_USING_SECURE_MEMORY
385 #define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
386 #define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
387 #define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
388 #define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
389 #define JSONCPP_ISTREAM std::istream
390 #else
391 #define JSONCPP_STRING std::string
392 #define JSONCPP_OSTRINGSTREAM std::ostringstream
393 #define JSONCPP_OSTREAM std::ostream
394 #define JSONCPP_ISTRINGSTREAM std::istringstream
395 #define JSONCPP_ISTREAM std::istream
396 #endif // if JSONCPP_USING_SECURE_MEMORY
397 } // end namespace Json
398 
399 #endif // JSON_CONFIG_H_INCLUDED
400 
401 // //////////////////////////////////////////////////////////////////////
402 // End of content of file: include/json/config.h
403 // //////////////////////////////////////////////////////////////////////
404 
405 
406 
407 
408 
409 
410 // //////////////////////////////////////////////////////////////////////
411 // Beginning of content of file: include/json/forwards.h
412 // //////////////////////////////////////////////////////////////////////
413 
414 // Copyright 2007-2010 Baptiste Lepilleur
415 // Distributed under MIT license, or public domain if desired and
416 // recognized in your jurisdiction.
417 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
418 
419 #ifndef JSON_FORWARDS_H_INCLUDED
420 #define JSON_FORWARDS_H_INCLUDED
421 
422 #if !defined(JSON_IS_AMALGAMATION)
423 #include "config.h"
424 #endif // if !defined(JSON_IS_AMALGAMATION)
425 
426 namespace Json {
427 
428 // writer.h
429 class FastWriter;
430 class StyledWriter;
431 
432 // reader.h
433 class Reader;
434 
435 // features.h
436 class Features;
437 
438 // value.h
439 typedef unsigned int ArrayIndex;
440 class StaticString;
441 class Path;
442 class PathArgument;
443 class Value;
444 class ValueIteratorBase;
445 class ValueIterator;
446 class ValueConstIterator;
447 
448 } // namespace Json
449 
450 #endif // JSON_FORWARDS_H_INCLUDED
451 
452 // //////////////////////////////////////////////////////////////////////
453 // End of content of file: include/json/forwards.h
454 // //////////////////////////////////////////////////////////////////////
455 
456 
457 
458 
459 
460 
461 // //////////////////////////////////////////////////////////////////////
462 // Beginning of content of file: include/json/features.h
463 // //////////////////////////////////////////////////////////////////////
464 
465 // Copyright 2007-2010 Baptiste Lepilleur
466 // Distributed under MIT license, or public domain if desired and
467 // recognized in your jurisdiction.
468 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
469 
470 #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
471 #define CPPTL_JSON_FEATURES_H_INCLUDED
472 
473 #if !defined(JSON_IS_AMALGAMATION)
474 #include "forwards.h"
475 #endif // if !defined(JSON_IS_AMALGAMATION)
476 
477 namespace Json {
478 
483 class JSON_API Features {
484 public:
491  static Features all();
492 
499  static Features strictMode();
500 
503  Features();
504 
507 
511 
514 
517 };
518 
519 } // namespace Json
520 
521 #endif // CPPTL_JSON_FEATURES_H_INCLUDED
522 
523 // //////////////////////////////////////////////////////////////////////
524 // End of content of file: include/json/features.h
525 // //////////////////////////////////////////////////////////////////////
526 
527 
528 
529 
530 
531 
532 // //////////////////////////////////////////////////////////////////////
533 // Beginning of content of file: include/json/value.h
534 // //////////////////////////////////////////////////////////////////////
535 
536 // Copyright 2007-2010 Baptiste Lepilleur
537 // Distributed under MIT license, or public domain if desired and
538 // recognized in your jurisdiction.
539 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
540 
541 #ifndef CPPTL_JSON_H_INCLUDED
542 #define CPPTL_JSON_H_INCLUDED
543 
544 #if !defined(JSON_IS_AMALGAMATION)
545 #include "forwards.h"
546 #endif // if !defined(JSON_IS_AMALGAMATION)
547 #include <string>
548 #include <vector>
549 #include <exception>
550 
551 #ifndef JSON_USE_CPPTL_SMALLMAP
552 #include <map>
553 #else
554 #include <cpptl/smallmap.h>
555 #endif
556 #ifdef JSON_USE_CPPTL
557 #include <cpptl/forwards.h>
558 #endif
559 
560 //Conditional NORETURN attribute on the throw functions would:
561 // a) suppress false positives from static code analysis
562 // b) possibly improve optimization opportunities.
563 #if !defined(JSONCPP_NORETURN)
564 # if defined(_MSC_VER)
565 # define JSONCPP_NORETURN __declspec(noreturn)
566 # elif defined(__GNUC__)
567 # define JSONCPP_NORETURN __attribute__ ((__noreturn__))
568 # else
569 # define JSONCPP_NORETURN
570 # endif
571 #endif
572 
573 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
574 // be used by...
575 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
576 #pragma warning(push)
577 #pragma warning(disable : 4251)
578 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
579 
582 namespace Json {
583 
588 class JSON_API Exception : public std::exception {
589 public:
590  Exception(JSONCPP_STRING const& msg);
591  ~Exception() throw() JSONCPP_OVERRIDE;
592  char const* what() const throw() JSONCPP_OVERRIDE;
593 protected:
594  JSONCPP_STRING msg_;
595 };
596 
603 class JSON_API RuntimeError : public Exception {
604 public:
605  RuntimeError(JSONCPP_STRING const& msg);
606 };
607 
614 class JSON_API LogicError : public Exception {
615 public:
616  LogicError(JSONCPP_STRING const& msg);
617 };
618 
620 JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
622 JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
623 
626 enum ValueType {
627  nullValue = 0,
635 };
636 
643 };
644 
645 //# ifdef JSON_USE_CPPTL
646 // typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
647 // typedef CppTL::AnyEnumerator<const Value &> EnumValues;
648 //# endif
649 
664 class JSON_API StaticString {
665 public:
666  explicit StaticString(const char* czstring) : c_str_(czstring) {}
667 
668  operator const char*() const { return c_str_; }
669 
670  const char* c_str() const { return c_str_; }
671 
672 private:
673  const char* c_str_;
674 };
675 
710 class JSON_API Value {
711  friend class ValueIteratorBase;
712 public:
713  typedef std::vector<JSONCPP_STRING> Members;
714  typedef ValueIterator iterator;
716  typedef Json::UInt UInt;
717  typedef Json::Int Int;
718 #if defined(JSON_HAS_INT64)
719  typedef Json::UInt64 UInt64;
720  typedef Json::Int64 Int64;
721 #endif // defined(JSON_HAS_INT64)
722  typedef Json::LargestInt LargestInt;
723  typedef Json::LargestUInt LargestUInt;
724  typedef Json::ArrayIndex ArrayIndex;
725 
726  static const Value& null;
727  static const Value& nullRef;
728  static const LargestInt minLargestInt;
731  static const LargestInt maxLargestInt;
733  static const LargestUInt maxLargestUInt;
734 
736  static const Int minInt;
738  static const Int maxInt;
740  static const UInt maxUInt;
741 
742 #if defined(JSON_HAS_INT64)
743  static const Int64 minInt64;
746  static const Int64 maxInt64;
748  static const UInt64 maxUInt64;
749 #endif // defined(JSON_HAS_INT64)
750 
751 private:
752 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
753  class CZString {
754  public:
755  enum DuplicationPolicy {
756  noDuplication = 0,
757  duplicate,
758  duplicateOnCopy
759  };
760  CZString(ArrayIndex index);
761  CZString(char const* str, unsigned length, DuplicationPolicy allocate);
762  CZString(CZString const& other);
763 #if JSON_HAS_RVALUE_REFERENCES
764  CZString(CZString&& other);
765 #endif
766  ~CZString();
767  CZString& operator=(CZString other);
768  bool operator<(CZString const& other) const;
769  bool operator==(CZString const& other) const;
770  ArrayIndex index() const;
771  //const char* c_str() const; ///< \deprecated
772  char const* data() const;
773  unsigned length() const;
774  bool isStaticString() const;
775 
776  private:
777  void swap(CZString& other);
778 
779  struct StringStorage {
780  unsigned policy_: 2;
781  unsigned length_: 30; // 1GB max
782  };
783 
784  char const* cstr_; // actually, a prefixed string, unless policy is noDup
785  union {
786  ArrayIndex index_;
787  StringStorage storage_;
788  };
789  };
790 
791 public:
792 #ifndef JSON_USE_CPPTL_SMALLMAP
793  typedef std::map<CZString, Value> ObjectValues;
794 #else
795  typedef CppTL::SmallMap<CZString, Value> ObjectValues;
796 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
797 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
798 
799 public:
815  Value(ValueType type = nullValue);
816  Value(Int value);
817  Value(UInt value);
818 #if defined(JSON_HAS_INT64)
819  Value(Int64 value);
820  Value(UInt64 value);
821 #endif // if defined(JSON_HAS_INT64)
822  Value(double value);
823  Value(const char* value);
824  Value(const char* begin, const char* end);
825 
840  Value(const StaticString& value);
841  Value(const JSONCPP_STRING& value);
842 #ifdef JSON_USE_CPPTL
843  Value(const CppTL::ConstString& value);
844 #endif
845  Value(bool value);
847  Value(const Value& other);
848 #if JSON_HAS_RVALUE_REFERENCES
849  Value(Value&& other);
851 #endif
852  ~Value();
853 
856  Value& operator=(Value other);
858  void swap(Value& other);
860  void swapPayload(Value& other);
861 
862  ValueType type() const;
863 
865  bool operator<(const Value& other) const;
866  bool operator<=(const Value& other) const;
867  bool operator>=(const Value& other) const;
868  bool operator>(const Value& other) const;
869  bool operator==(const Value& other) const;
870  bool operator!=(const Value& other) const;
871  int compare(const Value& other) const;
872 
873  const char* asCString() const;
874 #if JSONCPP_USING_SECURE_MEMORY
875  unsigned getCStringLength() const; //Allows you to understand the length of the CString
876 #endif
877  JSONCPP_STRING asString() const;
878 
881  bool getString(
882  char const** begin, char const** end) const;
883 #ifdef JSON_USE_CPPTL
884  CppTL::ConstString asConstString() const;
885 #endif
886  Int asInt() const;
887  UInt asUInt() const;
888 #if defined(JSON_HAS_INT64)
889  Int64 asInt64() const;
890  UInt64 asUInt64() const;
891 #endif // if defined(JSON_HAS_INT64)
892  LargestInt asLargestInt() const;
893  LargestUInt asLargestUInt() const;
894  float asFloat() const;
895  double asDouble() const;
896  bool asBool() const;
897 
898  bool isNull() const;
899  bool isBool() const;
900  bool isInt() const;
901  bool isInt64() const;
902  bool isUInt() const;
903  bool isUInt64() const;
904  bool isIntegral() const;
905  bool isDouble() const;
906  bool isNumeric() const;
907  bool isString() const;
908  bool isArray() const;
909  bool isObject() const;
910 
911  bool isConvertibleTo(ValueType other) const;
912 
914  ArrayIndex size() const;
915 
918  bool empty() const;
919 
921  bool operator!() const;
922 
926  void clear();
927 
933  void resize(ArrayIndex size);
934 
941  Value& operator[](ArrayIndex index);
942 
949  Value& operator[](int index);
950 
954  const Value& operator[](ArrayIndex index) const;
955 
959  const Value& operator[](int index) const;
960 
964  Value get(ArrayIndex index, const Value& defaultValue) const;
966  bool isValidIndex(ArrayIndex index) const;
970  Value& append(const Value& value);
971 
975  Value& operator[](const char* key);
978  const Value& operator[](const char* key) const;
981  Value& operator[](const JSONCPP_STRING& key);
985  const Value& operator[](const JSONCPP_STRING& key) const;
998  Value& operator[](const StaticString& key);
999 #ifdef JSON_USE_CPPTL
1000  Value& operator[](const CppTL::ConstString& key);
1004  const Value& operator[](const CppTL::ConstString& key) const;
1005 #endif
1006  Value get(const char* key, const Value& defaultValue) const;
1012  Value get(const char* begin, const char* end, const Value& defaultValue) const;
1016  Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
1017 #ifdef JSON_USE_CPPTL
1018  Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
1021 #endif
1022  Value const* find(char const* begin, char const* end) const;
1029  Value const* demand(char const* begin, char const* end);
1037  Value removeMember(const char* key);
1041  Value removeMember(const JSONCPP_STRING& key);
1044  bool removeMember(const char* key, Value* removed);
1051  bool removeMember(JSONCPP_STRING const& key, Value* removed);
1053  bool removeMember(const char* begin, const char* end, Value* removed);
1060  bool removeIndex(ArrayIndex i, Value* removed);
1061 
1064  bool isMember(const char* key) const;
1067  bool isMember(const JSONCPP_STRING& key) const;
1069  bool isMember(const char* begin, const char* end) const;
1070 #ifdef JSON_USE_CPPTL
1071  bool isMember(const CppTL::ConstString& key) const;
1073 #endif
1074 
1080  Members getMemberNames() const;
1081 
1082  //# ifdef JSON_USE_CPPTL
1083  // EnumMemberNames enumMemberNames() const;
1084  // EnumValues enumValues() const;
1085  //# endif
1086 
1088  JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
1089  void setComment(const char* comment, CommentPlacement placement);
1091  void setComment(const char* comment, size_t len, CommentPlacement placement);
1093  void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
1094  bool hasComment(CommentPlacement placement) const;
1096  JSONCPP_STRING getComment(CommentPlacement placement) const;
1097 
1098  JSONCPP_STRING toStyledString() const;
1099 
1100  const_iterator begin() const;
1101  const_iterator end() const;
1102 
1103  iterator begin();
1104  iterator end();
1105 
1106  // Accessors for the [start, limit) range of bytes within the JSON text from
1107  // which this value was parsed, if any.
1108  void setOffsetStart(ptrdiff_t start);
1109  void setOffsetLimit(ptrdiff_t limit);
1110  ptrdiff_t getOffsetStart() const;
1111  ptrdiff_t getOffsetLimit() const;
1112 
1113 private:
1114  void initBasic(ValueType type, bool allocated = false);
1115 
1116  Value& resolveReference(const char* key);
1117  Value& resolveReference(const char* key, const char* end);
1118 
1119  struct CommentInfo {
1120  CommentInfo();
1121  ~CommentInfo();
1122 
1123  void setComment(const char* text, size_t len);
1124 
1125  char* comment_;
1126  };
1127 
1128  // struct MemberNamesTransform
1129  //{
1130  // typedef const char *result_type;
1131  // const char *operator()( const CZString &name ) const
1132  // {
1133  // return name.c_str();
1134  // }
1135  //};
1136 
1137  union ValueHolder {
1138  LargestInt int_;
1139  LargestUInt uint_;
1140  double real_;
1141  bool bool_;
1142  char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
1143  ObjectValues* map_;
1144  } value_;
1145  ValueType type_ : 8;
1146  unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
1147  // If not allocated_, string_ must be null-terminated.
1148  CommentInfo* comments_;
1149 
1150  // [start, limit) byte offsets in the source JSON text from which this Value
1151  // was extracted.
1152  ptrdiff_t start_;
1153  ptrdiff_t limit_;
1154 };
1155 
1159 class JSON_API PathArgument {
1160 public:
1161  friend class Path;
1162 
1163  PathArgument();
1164  PathArgument(ArrayIndex index);
1165  PathArgument(const char* key);
1166  PathArgument(const JSONCPP_STRING& key);
1167 
1168 private:
1169  enum Kind {
1170  kindNone = 0,
1171  kindIndex,
1172  kindKey
1173  };
1174  JSONCPP_STRING key_;
1175  ArrayIndex index_;
1176  Kind kind_;
1177 };
1178 
1190 class JSON_API Path {
1191 public:
1192  Path(const JSONCPP_STRING& path,
1193  const PathArgument& a1 = PathArgument(),
1194  const PathArgument& a2 = PathArgument(),
1195  const PathArgument& a3 = PathArgument(),
1196  const PathArgument& a4 = PathArgument(),
1197  const PathArgument& a5 = PathArgument());
1198 
1199  const Value& resolve(const Value& root) const;
1200  Value resolve(const Value& root, const Value& defaultValue) const;
1203  Value& make(Value& root) const;
1204 
1205 private:
1206  typedef std::vector<const PathArgument*> InArgs;
1207  typedef std::vector<PathArgument> Args;
1208 
1209  void makePath(const JSONCPP_STRING& path, const InArgs& in);
1210  void addPathInArg(const JSONCPP_STRING& path,
1211  const InArgs& in,
1212  InArgs::const_iterator& itInArg,
1213  PathArgument::Kind kind);
1214  void invalidPath(const JSONCPP_STRING& path, int location);
1215 
1216  Args args_;
1217 };
1218 
1222 class JSON_API ValueIteratorBase {
1223 public:
1224  typedef std::bidirectional_iterator_tag iterator_category;
1225  typedef unsigned int size_t;
1226  typedef int difference_type;
1227  typedef ValueIteratorBase SelfType;
1228 
1229  bool operator==(const SelfType& other) const { return isEqual(other); }
1230 
1231  bool operator!=(const SelfType& other) const { return !isEqual(other); }
1232 
1233  difference_type operator-(const SelfType& other) const {
1234  return other.computeDistance(*this);
1235  }
1236 
1239  Value key() const;
1240 
1242  UInt index() const;
1243 
1247  JSONCPP_STRING name() const;
1248 
1252  JSONCPP_DEPRECATED("Use `key = name();` instead.")
1253  char const* memberName() const;
1257  char const* memberName(char const** end) const;
1258 
1259 protected:
1260  Value& deref() const;
1261 
1262  void increment();
1263 
1264  void decrement();
1265 
1266  difference_type computeDistance(const SelfType& other) const;
1267 
1268  bool isEqual(const SelfType& other) const;
1269 
1270  void copy(const SelfType& other);
1271 
1272 private:
1273  Value::ObjectValues::iterator current_;
1274  // Indicates that iterator is for a null value.
1275  bool isNull_;
1276 
1277 public:
1278  // For some reason, BORLAND needs these at the end, rather
1279  // than earlier. No idea why.
1281  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
1282 };
1283 
1287 class JSON_API ValueConstIterator : public ValueIteratorBase {
1288  friend class Value;
1289 
1290 public:
1291  typedef const Value value_type;
1292  //typedef unsigned int size_t;
1293  //typedef int difference_type;
1294  typedef const Value& reference;
1295  typedef const Value* pointer;
1296  typedef ValueConstIterator SelfType;
1297 
1299  ValueConstIterator(ValueIterator const& other);
1300 
1301 private:
1304  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
1305 public:
1306  SelfType& operator=(const ValueIteratorBase& other);
1307 
1308  SelfType operator++(int) {
1309  SelfType temp(*this);
1310  ++*this;
1311  return temp;
1312  }
1313 
1314  SelfType operator--(int) {
1315  SelfType temp(*this);
1316  --*this;
1317  return temp;
1318  }
1319 
1320  SelfType& operator--() {
1321  decrement();
1322  return *this;
1323  }
1324 
1325  SelfType& operator++() {
1326  increment();
1327  return *this;
1328  }
1329 
1330  reference operator*() const { return deref(); }
1331 
1332  pointer operator->() const { return &deref(); }
1333 };
1334 
1337 class JSON_API ValueIterator : public ValueIteratorBase {
1338  friend class Value;
1339 
1340 public:
1341  typedef Value value_type;
1342  typedef unsigned int size_t;
1343  typedef int difference_type;
1344  typedef Value& reference;
1345  typedef Value* pointer;
1346  typedef ValueIterator SelfType;
1347 
1348  ValueIterator();
1349  explicit ValueIterator(const ValueConstIterator& other);
1350  ValueIterator(const ValueIterator& other);
1351 
1352 private:
1355  explicit ValueIterator(const Value::ObjectValues::iterator& current);
1356 public:
1357  SelfType& operator=(const SelfType& other);
1358 
1359  SelfType operator++(int) {
1360  SelfType temp(*this);
1361  ++*this;
1362  return temp;
1363  }
1364 
1365  SelfType operator--(int) {
1366  SelfType temp(*this);
1367  --*this;
1368  return temp;
1369  }
1370 
1371  SelfType& operator--() {
1372  decrement();
1373  return *this;
1374  }
1375 
1376  SelfType& operator++() {
1377  increment();
1378  return *this;
1379  }
1380 
1381  reference operator*() const { return deref(); }
1382 
1383  pointer operator->() const { return &deref(); }
1384 };
1385 
1386 } // namespace Json
1387 
1388 
1389 namespace std {
1391 template<>
1392 inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
1393 }
1394 
1395 
1396 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1397 #pragma warning(pop)
1398 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1399 
1400 #endif // CPPTL_JSON_H_INCLUDED
1401 
1402 // //////////////////////////////////////////////////////////////////////
1403 // End of content of file: include/json/value.h
1404 // //////////////////////////////////////////////////////////////////////
1405 
1406 
1407 
1408 
1409 
1410 
1411 // //////////////////////////////////////////////////////////////////////
1412 // Beginning of content of file: include/json/reader.h
1413 // //////////////////////////////////////////////////////////////////////
1414 
1415 // Copyright 2007-2010 Baptiste Lepilleur
1416 // Distributed under MIT license, or public domain if desired and
1417 // recognized in your jurisdiction.
1418 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1419 
1420 #ifndef CPPTL_JSON_READER_H_INCLUDED
1421 #define CPPTL_JSON_READER_H_INCLUDED
1422 
1423 #if !defined(JSON_IS_AMALGAMATION)
1424 #include "features.h"
1425 #include "value.h"
1426 #endif // if !defined(JSON_IS_AMALGAMATION)
1427 #include <deque>
1428 #include <iosfwd>
1429 #include <stack>
1430 #include <string>
1431 #include <istream>
1432 
1433 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
1434 // be used by...
1435 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1436 #pragma warning(push)
1437 #pragma warning(disable : 4251)
1438 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1439 
1440 namespace Json {
1441 
1447 class JSON_API Reader {
1448 public:
1449  typedef char Char;
1450  typedef const Char* Location;
1451 
1459  ptrdiff_t offset_start;
1460  ptrdiff_t offset_limit;
1461  JSONCPP_STRING message;
1462  };
1463 
1467  Reader();
1468 
1472  Reader(const Features& features);
1473 
1488  bool
1489  parse(const std::string& document, Value& root, bool collectComments = true);
1490 
1509  bool parse(const char* beginDoc,
1510  const char* endDoc,
1511  Value& root,
1512  bool collectComments = true);
1513 
1516  bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
1517 
1527  JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
1528  JSONCPP_STRING getFormatedErrorMessages() const;
1529 
1538  JSONCPP_STRING getFormattedErrorMessages() const;
1539 
1547  std::vector<StructuredError> getStructuredErrors() const;
1548 
1555  bool pushError(const Value& value, const JSONCPP_STRING& message);
1556 
1564  bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
1565 
1570  bool good() const;
1571 
1572 private:
1573  enum TokenType {
1574  tokenEndOfStream = 0,
1575  tokenObjectBegin,
1576  tokenObjectEnd,
1577  tokenArrayBegin,
1578  tokenArrayEnd,
1579  tokenString,
1580  tokenNumber,
1581  tokenTrue,
1582  tokenFalse,
1583  tokenNull,
1584  tokenArraySeparator,
1585  tokenMemberSeparator,
1586  tokenComment,
1587  tokenError
1588  };
1589 
1590  class Token {
1591  public:
1592  TokenType type_;
1593  Location start_;
1594  Location end_;
1595  };
1596 
1597  class ErrorInfo {
1598  public:
1599  Token token_;
1600  JSONCPP_STRING message_;
1601  Location extra_;
1602  };
1603 
1604  typedef std::deque<ErrorInfo> Errors;
1605 
1606  bool readToken(Token& token);
1607  void skipSpaces();
1608  bool match(Location pattern, int patternLength);
1609  bool readComment();
1610  bool readCStyleComment();
1611  bool readCppStyleComment();
1612  bool readString();
1613  void readNumber();
1614  bool readValue();
1615  bool readObject(Token& token);
1616  bool readArray(Token& token);
1617  bool decodeNumber(Token& token);
1618  bool decodeNumber(Token& token, Value& decoded);
1619  bool decodeString(Token& token);
1620  bool decodeString(Token& token, JSONCPP_STRING& decoded);
1621  bool decodeDouble(Token& token);
1622  bool decodeDouble(Token& token, Value& decoded);
1623  bool decodeUnicodeCodePoint(Token& token,
1624  Location& current,
1625  Location end,
1626  unsigned int& unicode);
1627  bool decodeUnicodeEscapeSequence(Token& token,
1628  Location& current,
1629  Location end,
1630  unsigned int& unicode);
1631  bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
1632  bool recoverFromError(TokenType skipUntilToken);
1633  bool addErrorAndRecover(const JSONCPP_STRING& message,
1634  Token& token,
1635  TokenType skipUntilToken);
1636  void skipUntilSpace();
1637  Value& currentValue();
1638  Char getNextChar();
1639  void
1640  getLocationLineAndColumn(Location location, int& line, int& column) const;
1641  JSONCPP_STRING getLocationLineAndColumn(Location location) const;
1642  void addComment(Location begin, Location end, CommentPlacement placement);
1643  void skipCommentTokens(Token& token);
1644 
1645  typedef std::stack<Value*> Nodes;
1646  Nodes nodes_;
1647  Errors errors_;
1648  JSONCPP_STRING document_;
1649  Location begin_;
1650  Location end_;
1651  Location current_;
1652  Location lastValueEnd_;
1653  Value* lastValue_;
1654  JSONCPP_STRING commentsBefore_;
1655  Features features_;
1656  bool collectComments_;
1657 }; // Reader
1658 
1661 class JSON_API CharReader {
1662 public:
1663  virtual ~CharReader() {}
1681  virtual bool parse(
1682  char const* beginDoc, char const* endDoc,
1683  Value* root, JSONCPP_STRING* errs) = 0;
1684 
1685  class JSON_API Factory {
1686  public:
1687  virtual ~Factory() {}
1691  virtual CharReader* newCharReader() const = 0;
1692  }; // Factory
1693 }; // CharReader
1694 
1707 class JSON_API CharReaderBuilder : public CharReader::Factory {
1708 public:
1709  // Note: We use a Json::Value so that we can add data-members to this class
1710  // without a major version bump.
1748 
1750  ~CharReaderBuilder() JSONCPP_OVERRIDE;
1751 
1752  CharReader* newCharReader() const JSONCPP_OVERRIDE;
1753 
1757  bool validate(Json::Value* invalid) const;
1758 
1761  Value& operator[](JSONCPP_STRING key);
1762 
1768  static void setDefaults(Json::Value* settings);
1774  static void strictMode(Json::Value* settings);
1775 };
1776 
1781 bool JSON_API parseFromStream(
1782  CharReader::Factory const&,
1783  JSONCPP_ISTREAM&,
1784  Value* root, std::string* errs);
1785 
1810 JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
1811 
1812 } // namespace Json
1813 
1814 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1815 #pragma warning(pop)
1816 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1817 
1818 #endif // CPPTL_JSON_READER_H_INCLUDED
1819 
1820 // //////////////////////////////////////////////////////////////////////
1821 // End of content of file: include/json/reader.h
1822 // //////////////////////////////////////////////////////////////////////
1823 
1824 
1825 
1826 
1827 
1828 
1829 // //////////////////////////////////////////////////////////////////////
1830 // Beginning of content of file: include/json/writer.h
1831 // //////////////////////////////////////////////////////////////////////
1832 
1833 // Copyright 2007-2010 Baptiste Lepilleur
1834 // Distributed under MIT license, or public domain if desired and
1835 // recognized in your jurisdiction.
1836 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
1837 
1838 #ifndef JSON_WRITER_H_INCLUDED
1839 #define JSON_WRITER_H_INCLUDED
1840 
1841 #if !defined(JSON_IS_AMALGAMATION)
1842 #include "value.h"
1843 #endif // if !defined(JSON_IS_AMALGAMATION)
1844 #include <vector>
1845 #include <string>
1846 #include <ostream>
1847 
1848 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
1849 // be used by...
1850 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1851 #pragma warning(push)
1852 #pragma warning(disable : 4251)
1853 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1854 
1855 namespace Json {
1856 
1857 class Value;
1858 
1872 class JSON_API StreamWriter {
1873 protected:
1874  JSONCPP_OSTREAM* sout_; // not owned; will not delete
1875 public:
1876  StreamWriter();
1877  virtual ~StreamWriter();
1884  virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
1885 
1888  class JSON_API Factory {
1889  public:
1890  virtual ~Factory();
1894  virtual StreamWriter* newStreamWriter() const = 0;
1895  }; // Factory
1896 }; // StreamWriter
1897 
1901 JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
1902 
1903 
1920 public:
1921  // Note: We use a Json::Value so that we can add data-members to this class
1922  // without a major version bump.
1945 
1947  ~StreamWriterBuilder() JSONCPP_OVERRIDE;
1948 
1952  StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
1953 
1957  bool validate(Json::Value* invalid) const;
1960  Value& operator[](JSONCPP_STRING key);
1961 
1967  static void setDefaults(Json::Value* settings);
1968 };
1969 
1973 class JSON_API Writer {
1974 public:
1975  virtual ~Writer();
1976 
1977  virtual JSONCPP_STRING write(const Value& root) = 0;
1978 };
1979 
1989 class JSON_API FastWriter : public Writer {
1990 
1991 public:
1992  FastWriter();
1993  ~FastWriter() JSONCPP_OVERRIDE {}
1994 
1995  void enableYAMLCompatibility();
1996 
2002  void dropNullPlaceholders();
2003 
2004  void omitEndingLineFeed();
2005 
2006 public: // overridden from Writer
2007  JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
2008 
2009 private:
2010  void writeValue(const Value& value);
2011 
2012  JSONCPP_STRING document_;
2013  bool yamlCompatiblityEnabled_;
2014  bool dropNullPlaceholders_;
2015  bool omitEndingLineFeed_;
2016 };
2017 
2042 class JSON_API StyledWriter : public Writer {
2043 public:
2044  StyledWriter();
2045  ~StyledWriter() JSONCPP_OVERRIDE {}
2046 
2047 public: // overridden from Writer
2052  JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
2053 
2054 private:
2055  void writeValue(const Value& value);
2056  void writeArrayValue(const Value& value);
2057  bool isMultineArray(const Value& value);
2058  void pushValue(const JSONCPP_STRING& value);
2059  void writeIndent();
2060  void writeWithIndent(const JSONCPP_STRING& value);
2061  void indent();
2062  void unindent();
2063  void writeCommentBeforeValue(const Value& root);
2064  void writeCommentAfterValueOnSameLine(const Value& root);
2065  bool hasCommentForValue(const Value& value);
2066  static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
2067 
2068  typedef std::vector<JSONCPP_STRING> ChildValues;
2069 
2070  ChildValues childValues_;
2071  JSONCPP_STRING document_;
2072  JSONCPP_STRING indentString_;
2073  unsigned int rightMargin_;
2074  unsigned int indentSize_;
2075  bool addChildValues_;
2076 };
2077 
2104 class JSON_API StyledStreamWriter {
2105 public:
2106  StyledStreamWriter(JSONCPP_STRING indentation = "\t");
2107  ~StyledStreamWriter() {}
2108 
2109 public:
2116  void write(JSONCPP_OSTREAM& out, const Value& root);
2117 
2118 private:
2119  void writeValue(const Value& value);
2120  void writeArrayValue(const Value& value);
2121  bool isMultineArray(const Value& value);
2122  void pushValue(const JSONCPP_STRING& value);
2123  void writeIndent();
2124  void writeWithIndent(const JSONCPP_STRING& value);
2125  void indent();
2126  void unindent();
2127  void writeCommentBeforeValue(const Value& root);
2128  void writeCommentAfterValueOnSameLine(const Value& root);
2129  bool hasCommentForValue(const Value& value);
2130  static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
2131 
2132  typedef std::vector<JSONCPP_STRING> ChildValues;
2133 
2134  ChildValues childValues_;
2135  JSONCPP_OSTREAM* document_;
2136  JSONCPP_STRING indentString_;
2137  unsigned int rightMargin_;
2138  JSONCPP_STRING indentation_;
2139  bool addChildValues_ : 1;
2140  bool indented_ : 1;
2141 };
2142 
2143 #if defined(JSON_HAS_INT64)
2144 JSONCPP_STRING JSON_API valueToString(Int value);
2145 JSONCPP_STRING JSON_API valueToString(UInt value);
2146 #endif // if defined(JSON_HAS_INT64)
2147 JSONCPP_STRING JSON_API valueToString(LargestInt value);
2148 JSONCPP_STRING JSON_API valueToString(LargestUInt value);
2149 JSONCPP_STRING JSON_API valueToString(double value);
2150 JSONCPP_STRING JSON_API valueToString(bool value);
2151 JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
2152 
2155 JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
2156 
2157 } // namespace Json
2158 
2159 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2160 #pragma warning(pop)
2161 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2162 
2163 #endif // JSON_WRITER_H_INCLUDED
2164 
2165 // //////////////////////////////////////////////////////////////////////
2166 // End of content of file: include/json/writer.h
2167 // //////////////////////////////////////////////////////////////////////
2168 
2169 
2170 
2171 
2172 
2173 
2174 // //////////////////////////////////////////////////////////////////////
2175 // Beginning of content of file: include/json/assertions.h
2176 // //////////////////////////////////////////////////////////////////////
2177 
2178 // Copyright 2007-2010 Baptiste Lepilleur
2179 // Distributed under MIT license, or public domain if desired and
2180 // recognized in your jurisdiction.
2181 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2182 
2183 #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
2184 #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
2185 
2186 #include <stdlib.h>
2187 #include <sstream>
2188 
2189 #if !defined(JSON_IS_AMALGAMATION)
2190 #include "config.h"
2191 #endif // if !defined(JSON_IS_AMALGAMATION)
2192 
2197 #if JSON_USE_EXCEPTION
2198 
2199 // @todo <= add detail about condition in exception
2200 # define JSON_ASSERT(condition) \
2201  {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
2202 
2203 # define JSON_FAIL_MESSAGE(message) \
2204  { \
2205  JSONCPP_OSTRINGSTREAM oss; oss << message; \
2206  Json::throwLogicError(oss.str()); \
2207  abort(); \
2208  }
2209 
2210 #else // JSON_USE_EXCEPTION
2211 
2212 # define JSON_ASSERT(condition) assert(condition)
2213 
2214 // The call to assert() will show the failure message in debug builds. In
2215 // release builds we abort, for a core-dump or debugger.
2216 # define JSON_FAIL_MESSAGE(message) \
2217  { \
2218  JSONCPP_OSTRINGSTREAM oss; oss << message; \
2219  assert(false && oss.str().c_str()); \
2220  abort(); \
2221  }
2222 
2223 
2224 #endif
2225 
2226 #define JSON_ASSERT_MESSAGE(condition, message) \
2227  if (!(condition)) { \
2228  JSON_FAIL_MESSAGE(message); \
2229  }
2230 
2231 #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
2232 
2233 // //////////////////////////////////////////////////////////////////////
2234 // End of content of file: include/json/assertions.h
2235 // //////////////////////////////////////////////////////////////////////
2236 
2237 
2238 
2239 
2240 
2241 #endif //ifndef JSON_AMALGATED_H_INCLUDED
Outputs a Value in JSON format without formatting (not human friendly).
Definition: json.hpp:1989
void construct(pointer p, Args &&...args)
Definition: json.hpp:168
A simple abstract factory.
Definition: json.hpp:1888
Writes a Value in JSON format in a human friendly way.
Definition: json.hpp:2042
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition: json.hpp:746
static const Value & null
We regret this reference to a global instance; prefer the simpler Value().
Definition: json.hpp:726
base class for Value iterators.
Definition: json.hpp:1222
array value (ordered list)
Definition: json.hpp:633
JSONCPP_STRING JSON_API 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:5224
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const &msg)
used internally
Definition: jsoncpp.cpp:2616
unsigned integer value
Definition: json.hpp:629
Json::Value settings_
Definition: json.hpp:1747
root value)
Definition: json.hpp:642
Definition: json.hpp:1872
Definition: json.hpp:614
object value (collection of name/value pairs).
Definition: json.hpp:634
bool JSON_API parseFromStream(CharReader::Factory const &, JSONCPP_ISTREAM &, Value *root, std::string *errs)
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition: json.hpp:738
Definition: BTagger.hpp:102
Definition: json.hpp:196
Lightweight wrapper to tag static string.
Definition: json.hpp:664
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition: json.hpp:740
An error tagged with where in the JSON text it was encountered.
Definition: json.hpp:1458
const iterator for object and array value.
Definition: json.hpp:1287
pointer allocate(size_type n)
Definition: json.hpp:146
Experimental and untested: represents an element of the "path" to access a node.
Definition: json.hpp:1159
void destroy(pointer p)
Definition: json.hpp:188
'null' value
Definition: json.hpp:627
bool allowComments_
true if comments are allowed. Default: true.
Definition: json.hpp:506
CommentPlacement
Definition: json.hpp:637
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const &msg)
used internally
Definition: jsoncpp.cpp:2620
static const Value & nullRef
Definition: json.hpp:727
bool allowNumericKeys_
true if numeric object key are allowed. Default: false.
Definition: json.hpp:516
JSON (JavaScript Object Notation).
Definition: json.hpp:130
bool allowDroppedNullPlaceholders_
true if dropped null placeholders are allowed. Default: false.
Definition: json.hpp:513
void swap(Value &other)
Swap everything.
Definition: jsoncpp.cpp:2932
Experimental and untested: represents a "path" to access a node.
Definition: json.hpp:1190
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition: json.hpp:748
double value
Definition: json.hpp:630
Definition: json.hpp:1661
Json::Value settings_
Definition: json.hpp:1944
Abstract class for writers.
Definition: json.hpp:1973
Represents a JSON value.
Definition: json.hpp:710
JSON_API JSONCPP_OSTREAM & operator<<(JSONCPP_OSTREAM &, const Value &root)
Output using the StyledStreamWriter.
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition: json.hpp:736
Definition: json.hpp:603
Definition: json.hpp:640
Unserialize a JSON document into a Value.
Definition: json.hpp:1447
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
Definition: json.hpp:2104
Iterator for object and array value.
Definition: json.hpp:1337
ValueType
Type of the value held by a Value object.
Definition: json.hpp:626
bool strictRoot_
Definition: json.hpp:510
Definition: json.hpp:132
bool value
Definition: json.hpp:632
signed integer value
Definition: json.hpp:628
Build a CharReader implementation.
Definition: json.hpp:1707
Definition: json.hpp:1685
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition: json.hpp:483
a comment placed on the line before a value
Definition: json.hpp:638
UTF-8 string value.
Definition: json.hpp:631
a comment just after a value on the same line
Definition: json.hpp:639
Build a StreamWriter implementation.
Definition: json.hpp:1919
Definition: json.hpp:588
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition: json.hpp:731
void deallocate(volatile pointer p, size_type n)
Definition: json.hpp:158
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition: json.hpp:733