75 #ifndef JSON_AMALGATED_H_INCLUDED
76 # define JSON_AMALGATED_H_INCLUDED
77 #define JSON_IS_AMALGAMATION
87 #ifndef JSON_VERSION_H_INCLUDED
88 # define JSON_VERSION_H_INCLUDED
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))
97 #ifdef JSONCPP_USING_SECURE_MEMORY
98 #undef JSONCPP_USING_SECURE_MEMORY
100 #define JSONCPP_USING_SECURE_MEMORY 0
104 #endif // JSON_VERSION_H_INCLUDED
124 #ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
125 #define CPPTL_JSON_ALLOCATOR_H_INCLUDED
135 using value_type = 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;
148 return static_cast<pointer
>(::operator
new(n *
sizeof(T)));
159 std::memset(p, 0, n *
sizeof(T));
161 ::operator
delete(p);
167 template<
typename... Args>
170 ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
173 size_type max_size()
const {
174 return size_t(-1) /
sizeof(T);
177 pointer address( reference x )
const {
178 return std::addressof(x);
181 const_pointer address( const_reference x )
const {
182 return std::addressof(x);
195 template<
typename U> SecureAllocator(
const SecureAllocator<U>&) {}
200 template<
typename T,
typename U>
205 template<
typename T,
typename U>
206 bool operator!=(
const SecureAllocator<T>&,
const SecureAllocator<U>&) {
212 #endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
232 #ifndef JSON_CONFIG_H_INCLUDED
233 #define JSON_CONFIG_H_INCLUDED
249 #ifndef JSON_USE_EXCEPTION
250 #define JSON_USE_EXCEPTION 1
259 #include <cpptl/config.h>
260 #ifndef JSON_USE_CPPTL
261 #define JSON_USE_CPPTL 1
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)
287 #if defined(_MSC_VER) // MSVC
288 # if _MSC_VER <= 1200 // MSVC 6
291 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
296 # pragma warning(disable : 4786)
299 # if _MSC_VER >= 1500 // MSVC 2008
300 # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
304 #endif // defined(_MSC_VER)
306 #if defined(_MSC_VER) && _MSC_VER <= 1600 // MSVC <= 2010
307 # define JSONCPP_OVERRIDE
309 # define JSONCPP_OVERRIDE override
310 #endif // MSVC <= 2010
313 #ifndef JSON_HAS_RVALUE_REFERENCES
315 #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
316 #define JSON_HAS_RVALUE_REFERENCES 1
317 #endif // MSVC >= 2010
320 #if __has_feature(cxx_rvalue_references)
321 #define JSON_HAS_RVALUE_REFERENCES 1
322 #endif // has_feature
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
329 #endif // __clang__ || __GNUC__
331 #endif // not defined JSON_HAS_RVALUE_REFERENCES
333 #ifndef JSON_HAS_RVALUE_REFERENCES
334 #define JSON_HAS_RVALUE_REFERENCES 0
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__
346 #if !defined(JSONCPP_DEPRECATED)
347 #define JSONCPP_DEPRECATED(message)
348 #endif // if !defined(JSONCPP_DEPRECATED)
351 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
354 #if !defined(JSON_IS_AMALGAMATION)
356 # include "version.h"
358 # if JSONCPP_USING_SECURE_MEMORY
359 # include "allocator.h"
362 #endif // if !defined(JSON_IS_AMALGAMATION)
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)
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
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
399 #endif // JSON_CONFIG_H_INCLUDED
419 #ifndef JSON_FORWARDS_H_INCLUDED
420 #define JSON_FORWARDS_H_INCLUDED
422 #if !defined(JSON_IS_AMALGAMATION)
424 #endif // if !defined(JSON_IS_AMALGAMATION)
439 typedef unsigned int ArrayIndex;
444 class ValueIteratorBase;
446 class ValueConstIterator;
450 #endif // JSON_FORWARDS_H_INCLUDED
470 #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
471 #define CPPTL_JSON_FEATURES_H_INCLUDED
473 #if !defined(JSON_IS_AMALGAMATION)
474 #include "forwards.h"
475 #endif // if !defined(JSON_IS_AMALGAMATION)
521 #endif // CPPTL_JSON_FEATURES_H_INCLUDED
541 #ifndef CPPTL_JSON_H_INCLUDED
542 #define CPPTL_JSON_H_INCLUDED
544 #if !defined(JSON_IS_AMALGAMATION)
545 #include "forwards.h"
546 #endif // if !defined(JSON_IS_AMALGAMATION)
551 #ifndef JSON_USE_CPPTL_SMALLMAP
554 #include <cpptl/smallmap.h>
556 #ifdef JSON_USE_CPPTL
557 #include <cpptl/forwards.h>
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__))
569 # define JSONCPP_NORETURN
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)
592 char const* what()
const throw() JSONCPP_OVERRIDE;
666 explicit StaticString(
const char* czstring) : c_str_(czstring) {}
668 operator const char*()
const {
return c_str_; }
670 const char* c_str()
const {
return c_str_; }
713 typedef std::vector<JSONCPP_STRING> Members;
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;
728 static const LargestInt minLargestInt;
742 #if defined(JSON_HAS_INT64)
743 static const Int64 minInt64;
749 #endif // defined(JSON_HAS_INT64)
752 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
755 enum DuplicationPolicy {
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);
767 CZString& operator=(CZString other);
768 bool operator<(CZString
const& other)
const;
769 bool operator==(CZString
const& other)
const;
770 ArrayIndex index()
const;
772 char const* data()
const;
773 unsigned length()
const;
774 bool isStaticString()
const;
777 void swap(CZString& other);
779 struct StringStorage {
781 unsigned length_: 30;
787 StringStorage storage_;
792 #ifndef JSON_USE_CPPTL_SMALLMAP
793 typedef std::map<CZString, Value> ObjectValues;
795 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
796 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
797 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
818 #if defined(JSON_HAS_INT64)
821 #endif // if defined(JSON_HAS_INT64)
823 Value(
const char* value);
824 Value(
const char* begin,
const char* end);
841 Value(
const JSONCPP_STRING& value);
842 #ifdef JSON_USE_CPPTL
843 Value(
const CppTL::ConstString& value);
848 #if JSON_HAS_RVALUE_REFERENCES
858 void swap(
Value& other);
860 void swapPayload(
Value& other);
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;
873 const char* asCString()
const;
874 #if JSONCPP_USING_SECURE_MEMORY
875 unsigned getCStringLength()
const;
877 JSONCPP_STRING asString()
const;
882 char const** begin,
char const** end)
const;
883 #ifdef JSON_USE_CPPTL
884 CppTL::ConstString asConstString()
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;
901 bool isInt64()
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;
911 bool isConvertibleTo(
ValueType other)
const;
914 ArrayIndex size()
const;
921 bool operator!()
const;
933 void resize(ArrayIndex size);
941 Value& operator[](ArrayIndex index);
949 Value& operator[](
int index);
954 const Value& operator[](ArrayIndex index)
const;
959 const Value& operator[](
int index)
const;
964 Value get(ArrayIndex index,
const Value& defaultValue)
const;
966 bool isValidIndex(ArrayIndex index)
const;
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;
999 #ifdef JSON_USE_CPPTL
1000 Value& operator[](
const CppTL::ConstString& key);
1004 const Value& operator[](
const CppTL::ConstString& key)
const;
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;
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);
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;
1080 Members getMemberNames()
const;
1088 JSONCPP_DEPRECATED(
"Use setComment(JSONCPP_STRING const&) instead.")
1091 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
1093 void setComment(const JSONCPP_STRING& comment,
CommentPlacement placement);
1098 JSONCPP_STRING toStyledString() const;
1100 const_iterator begin() const;
1101 const_iterator end() const;
1108 void setOffsetStart(ptrdiff_t start);
1109 void setOffsetLimit(ptrdiff_t limit);
1110 ptrdiff_t getOffsetStart() const;
1111 ptrdiff_t getOffsetLimit() const;
1114 void initBasic(
ValueType type,
bool allocated = false);
1116 Value& resolveReference(const
char* key);
1117 Value& resolveReference(const
char* key, const
char* end);
1119 struct CommentInfo {
1123 void setComment(
const char* text,
size_t len);
1146 unsigned int allocated_ : 1;
1148 CommentInfo* comments_;
1174 JSONCPP_STRING key_;
1192 Path(
const JSONCPP_STRING& path,
1199 const Value& resolve(
const Value& root)
const;
1206 typedef std::vector<const PathArgument*> InArgs;
1207 typedef std::vector<PathArgument> Args;
1209 void makePath(
const JSONCPP_STRING& path,
const InArgs& in);
1210 void addPathInArg(
const JSONCPP_STRING& path,
1212 InArgs::const_iterator& itInArg,
1213 PathArgument::Kind kind);
1214 void invalidPath(
const JSONCPP_STRING& path,
int location);
1224 typedef std::bidirectional_iterator_tag iterator_category;
1225 typedef unsigned int size_t;
1226 typedef int difference_type;
1229 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
1231 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
1233 difference_type operator-(
const SelfType& other)
const {
1234 return other.computeDistance(*
this);
1247 JSONCPP_STRING name()
const;
1252 JSONCPP_DEPRECATED(
"Use `key = name();` instead.")
1253 char const* memberName()
const;
1257 char const* memberName(
char const** end)
const;
1260 Value& deref()
const;
1266 difference_type computeDistance(
const SelfType& other)
const;
1268 bool isEqual(
const SelfType& other)
const;
1270 void copy(
const SelfType& other);
1273 Value::ObjectValues::iterator current_;
1308 SelfType operator++(
int) {
1309 SelfType temp(*
this);
1314 SelfType operator--(
int) {
1315 SelfType temp(*
this);
1320 SelfType& operator--() {
1325 SelfType& operator++() {
1330 reference operator*()
const {
return deref(); }
1332 pointer operator->()
const {
return &deref(); }
1342 typedef unsigned int size_t;
1343 typedef int difference_type;
1355 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
1357 SelfType& operator=(
const SelfType& other);
1359 SelfType operator++(
int) {
1360 SelfType temp(*
this);
1365 SelfType operator--(
int) {
1366 SelfType temp(*
this);
1371 SelfType& operator--() {
1376 SelfType& operator++() {
1381 reference operator*()
const {
return deref(); }
1383 pointer operator->()
const {
return &deref(); }
1396 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1397 #pragma warning(pop)
1398 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1400 #endif // CPPTL_JSON_H_INCLUDED
1420 #ifndef CPPTL_JSON_READER_H_INCLUDED
1421 #define CPPTL_JSON_READER_H_INCLUDED
1423 #if !defined(JSON_IS_AMALGAMATION)
1424 #include "features.h"
1426 #endif // if !defined(JSON_IS_AMALGAMATION)
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)
1450 typedef const Char* Location;
1459 ptrdiff_t offset_start;
1460 ptrdiff_t offset_limit;
1461 JSONCPP_STRING message;
1489 parse(
const std::string& document,
Value& root,
bool collectComments =
true);
1509 bool parse(
const char* beginDoc,
1512 bool collectComments =
true);
1516 bool parse(JSONCPP_ISTREAM& is,
Value& root,
bool collectComments =
true);
1527 JSONCPP_DEPRECATED(
"Use getFormattedErrorMessages() instead.")
1528 JSONCPP_STRING getFormatedErrorMessages() const;
1538 JSONCPP_STRING getFormattedErrorMessages() const;
1555 bool pushError(const
Value& value, const JSONCPP_STRING& message);
1564 bool pushError(const
Value& value, const JSONCPP_STRING& message, const
Value& extra);
1574 tokenEndOfStream = 0,
1584 tokenArraySeparator,
1585 tokenMemberSeparator,
1600 JSONCPP_STRING message_;
1604 typedef std::deque<ErrorInfo> Errors;
1606 bool readToken(Token& token);
1608 bool match(Location pattern,
int patternLength);
1610 bool readCStyleComment();
1611 bool readCppStyleComment();
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,
1626 unsigned int& unicode);
1627 bool decodeUnicodeEscapeSequence(Token& token,
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,
1635 TokenType skipUntilToken);
1636 void skipUntilSpace();
1637 Value& currentValue();
1640 getLocationLineAndColumn(Location location,
int& line,
int& column)
const;
1641 JSONCPP_STRING getLocationLineAndColumn(Location location)
const;
1643 void skipCommentTokens(Token& token);
1645 typedef std::stack<Value*> Nodes;
1648 JSONCPP_STRING document_;
1652 Location lastValueEnd_;
1654 JSONCPP_STRING commentsBefore_;
1656 bool collectComments_;
1682 char const* beginDoc,
char const* endDoc,
1683 Value* root, JSONCPP_STRING* errs) = 0;
1691 virtual CharReader* newCharReader()
const = 0;
1752 CharReader* newCharReader() const JSONCPP_OVERRIDE;
1757 bool validate(
Json::
Value* invalid) const;
1761 Value& operator[](JSONCPP_STRING key);
1768 static
void setDefaults(
Json::
Value* settings);
1774 static
void strictMode(
Json::
Value* settings);
1810 JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&,
Value&);
1814 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1815 #pragma warning(pop)
1816 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1818 #endif // CPPTL_JSON_READER_H_INCLUDED
1838 #ifndef JSON_WRITER_H_INCLUDED
1839 #define JSON_WRITER_H_INCLUDED
1841 #if !defined(JSON_IS_AMALGAMATION)
1843 #endif // if !defined(JSON_IS_AMALGAMATION)
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)
1874 JSONCPP_OSTREAM* sout_;
1884 virtual int write(Value
const& root, JSONCPP_OSTREAM* sout) = 0;
1952 StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
1957 bool validate(
Json::Value* invalid) const;
1960 Value& operator[](JSONCPP_STRING key);
1967 static
void setDefaults(
Json::Value* settings);
1977 virtual JSONCPP_STRING write(
const Value& root) = 0;
1995 void enableYAMLCompatibility();
2002 void dropNullPlaceholders();
2004 void omitEndingLineFeed();
2007 JSONCPP_STRING write(
const Value& root) JSONCPP_OVERRIDE;
2010 void writeValue(
const Value& value);
2012 JSONCPP_STRING document_;
2013 bool yamlCompatiblityEnabled_;
2014 bool dropNullPlaceholders_;
2015 bool omitEndingLineFeed_;
2052 JSONCPP_STRING write(
const Value& root) JSONCPP_OVERRIDE;
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);
2060 void writeWithIndent(
const JSONCPP_STRING& value);
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);
2068 typedef std::vector<JSONCPP_STRING> ChildValues;
2070 ChildValues childValues_;
2071 JSONCPP_STRING document_;
2072 JSONCPP_STRING indentString_;
2073 unsigned int rightMargin_;
2074 unsigned int indentSize_;
2075 bool addChildValues_;
2116 void write(JSONCPP_OSTREAM& out,
const Value& root);
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);
2124 void writeWithIndent(
const JSONCPP_STRING& value);
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);
2132 typedef std::vector<JSONCPP_STRING> ChildValues;
2134 ChildValues childValues_;
2135 JSONCPP_OSTREAM* document_;
2136 JSONCPP_STRING indentString_;
2137 unsigned int rightMargin_;
2138 JSONCPP_STRING indentation_;
2139 bool addChildValues_ : 1;
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);
2155 JSON_API JSONCPP_OSTREAM&
operator<<(JSONCPP_OSTREAM&,
const Value& root);
2159 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2160 #pragma warning(pop)
2161 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2163 #endif // JSON_WRITER_H_INCLUDED
2183 #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
2184 #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
2189 #if !defined(JSON_IS_AMALGAMATION)
2191 #endif // if !defined(JSON_IS_AMALGAMATION)
2197 #if JSON_USE_EXCEPTION
2200 # define JSON_ASSERT(condition) \
2201 {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
2203 # define JSON_FAIL_MESSAGE(message) \
2205 JSONCPP_OSTRINGSTREAM oss; oss << message; \
2206 Json::throwLogicError(oss.str()); \
2210 #else // JSON_USE_EXCEPTION
2212 # define JSON_ASSERT(condition) assert(condition)
2216 # define JSON_FAIL_MESSAGE(message) \
2218 JSONCPP_OSTRINGSTREAM oss; oss << message; \
2219 assert(false && oss.str().c_str()); \
2226 #define JSON_ASSERT_MESSAGE(condition, message) \
2227 if (!(condition)) { \
2228 JSON_FAIL_MESSAGE(message); \
2231 #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
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
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
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
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
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
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