75 #ifndef JSON_AMALGATED_H_INCLUDED
76 # define JSON_AMALGATED_H_INCLUDED
77 #define JSON_IS_AMALGAMATION
88 #ifndef JSON_VERSION_H_INCLUDED
89 # define JSON_VERSION_H_INCLUDED
91 # define JSONCPP_VERSION_STRING "1.6.2"
92 # define JSONCPP_VERSION_MAJOR 1
93 # define JSONCPP_VERSION_MINOR 6
94 # define JSONCPP_VERSION_PATCH 2
95 # define JSONCPP_VERSION_QUALIFIER
96 # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
98 #endif // JSON_VERSION_H_INCLUDED
118 #ifndef JSON_CONFIG_H_INCLUDED
119 #define JSON_CONFIG_H_INCLUDED
133 #ifndef JSON_USE_EXCEPTION
134 #define JSON_USE_EXCEPTION 1
143 #include <cpptl/config.h>
144 #ifndef JSON_USE_CPPTL
145 #define JSON_USE_CPPTL 1
150 #define JSON_API CPPTL_API
151 #elif defined(JSON_DLL_BUILD)
152 #if defined(_MSC_VER)
153 #define JSON_API __declspec(dllexport)
154 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
155 #endif // if defined(_MSC_VER)
156 #elif defined(JSON_DLL)
157 #if defined(_MSC_VER)
158 #define JSON_API __declspec(dllimport)
159 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
160 #endif // if defined(_MSC_VER)
161 #endif // ifdef JSON_IN_CPPTL
162 #if !defined(JSON_API)
171 #if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
174 #define JSON_USE_INT64_DOUBLE_CONVERSION 1
179 #pragma warning(disable : 4786)
180 #endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
182 #if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
183 #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
185 #elif defined(__clang__) && defined(__has_feature)
186 #if __has_feature(attribute_deprecated_with_message)
187 #define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
189 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
190 #define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
191 #elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
192 #define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
195 #if !defined(JSONCPP_DEPRECATED)
196 #define JSONCPP_DEPRECATED(message)
197 #endif // if !defined(JSONCPP_DEPRECATED)
201 typedef unsigned int UInt;
202 #if defined(JSON_NO_INT64)
205 #undef JSON_HAS_INT64
206 #else // if defined(JSON_NO_INT64)
208 #if defined(_MSC_VER) // Microsoft Visual Studio
209 typedef __int64
Int64;
210 typedef unsigned __int64
UInt64;
211 #else // if defined(_MSC_VER) // Other platforms, use long long
212 typedef long long int Int64;
213 typedef unsigned long long int UInt64;
214 #endif // if defined(_MSC_VER)
217 #define JSON_HAS_INT64
218 #endif // if defined(JSON_NO_INT64)
221 #endif // JSON_CONFIG_H_INCLUDED
241 #ifndef JSON_FORWARDS_H_INCLUDED
242 #define JSON_FORWARDS_H_INCLUDED
244 #if !defined(JSON_IS_AMALGAMATION)
246 #endif // if !defined(JSON_IS_AMALGAMATION)
266 class ValueIteratorBase;
268 class ValueConstIterator;
272 #endif // JSON_FORWARDS_H_INCLUDED
292 #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
293 #define CPPTL_JSON_FEATURES_H_INCLUDED
295 #if !defined(JSON_IS_AMALGAMATION)
296 #include "forwards.h"
297 #endif // if !defined(JSON_IS_AMALGAMATION)
343 #endif // CPPTL_JSON_FEATURES_H_INCLUDED
363 #ifndef CPPTL_JSON_H_INCLUDED
364 #define CPPTL_JSON_H_INCLUDED
366 #if !defined(JSON_IS_AMALGAMATION)
367 #include "forwards.h"
368 #endif // if !defined(JSON_IS_AMALGAMATION)
373 #ifndef JSON_USE_CPPTL_SMALLMAP
376 #include <cpptl/smallmap.h>
378 #ifdef JSON_USE_CPPTL
379 #include <cpptl/forwards.h>
384 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
385 #pragma warning(push)
386 #pragma warning(disable : 4251)
387 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
462 operator const char*()
const {
return c_str_; }
464 const char*
c_str()
const {
return c_str_; }
512 #if defined(JSON_HAS_INT64)
515 #endif // defined(JSON_HAS_INT64)
536 #if defined(JSON_HAS_INT64)
537 static const Int64 minInt64;
543 #endif // defined(JSON_HAS_INT64)
546 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
555 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
559 bool operator<(
CZString const& other)
const;
560 bool operator==(
CZString const& other)
const;
563 char const* data()
const;
564 unsigned length()
const;
565 bool isStaticString()
const;
572 unsigned length_: 30;
583 #ifndef JSON_USE_CPPTL_SMALLMAP
587 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
588 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
609 #if defined(JSON_HAS_INT64)
612 #endif // if defined(JSON_HAS_INT64)
614 Value(
const char* value);
615 Value(
const char* beginValue,
const char* endValue);
632 Value(
const std::string& value);
633 #ifdef JSON_USE_CPPTL
634 Value(
const CppTL::ConstString& value);
647 void swapPayload(
Value& other);
652 bool operator<(
const Value& other)
const;
653 bool operator<=(
const Value& other)
const;
654 bool operator>=(
const Value& other)
const;
655 bool operator>(
const Value& other)
const;
656 bool operator==(
const Value& other)
const;
657 bool operator!=(
const Value& other)
const;
658 int compare(
const Value& other)
const;
660 const char* asCString()
const;
661 std::string asString()
const;
666 char const** str,
char const** end)
const;
667 #ifdef JSON_USE_CPPTL
668 CppTL::ConstString asConstString()
const;
672 #if defined(JSON_HAS_INT64)
673 Int64 asInt64()
const;
675 #endif // if defined(JSON_HAS_INT64)
678 float asFloat()
const;
679 double asDouble()
const;
685 bool isInt64()
const;
687 bool isUInt64()
const;
688 bool isIntegral()
const;
689 bool isDouble()
const;
690 bool isNumeric()
const;
691 bool isString()
const;
692 bool isArray()
const;
693 bool isObject()
const;
695 bool isConvertibleTo(
ValueType other)
const;
705 bool operator!()
const;
733 Value& operator[](
int index);
743 const Value& operator[](
int index)
const;
759 Value& operator[](
const char* key);
762 const Value& operator[](
const char* key)
const;
765 Value& operator[](
const std::string& key);
769 const Value& operator[](
const std::string& key)
const;
783 #ifdef JSON_USE_CPPTL
784 Value& operator[](
const CppTL::ConstString& key);
788 const Value& operator[](
const CppTL::ConstString& key)
const;
790 Value get(
const char* key,
const Value& defaultValue)
const;
796 Value get(
const char* key,
const char* end,
const Value& defaultValue)
const;
800 Value get(
const std::string& key,
const Value& defaultValue)
const;
801 #ifdef JSON_USE_CPPTL
802 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
806 Value const* find(
char const* key,
char const* end)
const;
813 Value const* demand(
char const* key,
char const* end);
821 Value removeMember(
const char* key);
825 Value removeMember(
const std::string& key);
828 bool removeMember(
const char* key,
Value* removed);
835 bool removeMember(std::string
const& key,
Value* removed);
837 bool removeMember(
const char* key,
const char* end,
Value* removed);
848 bool isMember(
const char* key)
const;
851 bool isMember(
const std::string& key)
const;
853 bool isMember(
const char* key,
const char* end)
const;
854 #ifdef JSON_USE_CPPTL
855 bool isMember(
const CppTL::ConstString& key)
const;
864 Members getMemberNames()
const;
875 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
882 std::
string toStyledString() const;
892 void setOffsetStart(
size_t start);
893 void setOffsetLimit(
size_t limit);
894 size_t getOffsetStart() const;
895 size_t getOffsetLimit() const;
898 void initBasic(
ValueType type,
bool allocated = false);
900 Value& resolveReference(const
char* key);
901 Value& resolveReference(const
char* key, const
char* end);
907 void setComment(
const char* text,
size_t len);
930 unsigned int allocated_ : 1;
976 Path(
const std::string& path,
983 const Value& resolve(
const Value& root)
const;
990 typedef std::vector<const PathArgument*>
InArgs;
991 typedef std::vector<PathArgument>
Args;
993 void makePath(
const std::string& path,
const InArgs& in);
994 void addPathInArg(
const std::string& path,
996 InArgs::const_iterator& itInArg,
998 void invalidPath(
const std::string& path,
int location);
1031 std::string name()
const;
1037 char const* memberName() const;
1041 char const* memberName(
char const** end) const;
1044 Value& deref() const;
1050 difference_type computeDistance(const SelfType& other) const;
1052 bool isEqual(const SelfType& other) const;
1054 void copy(const SelfType& other);
1065 explicit ValueIteratorBase(const
Value::ObjectValues::iterator& current);
1089 SelfType& operator=(
const ValueIteratorBase& other);
1092 SelfType temp(*
this);
1098 SelfType temp(*
this);
1138 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
1179 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1180 #pragma warning(pop)
1181 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1183 #endif // CPPTL_JSON_H_INCLUDED
1203 #ifndef CPPTL_JSON_READER_H_INCLUDED
1204 #define CPPTL_JSON_READER_H_INCLUDED
1206 #if !defined(JSON_IS_AMALGAMATION)
1207 #include "features.h"
1209 #endif // if !defined(JSON_IS_AMALGAMATION)
1218 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1219 #pragma warning(push)
1220 #pragma warning(disable : 4251)
1221 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1272 parse(
const std::string& document,
Value& root,
bool collectComments =
true);
1292 bool parse(
const char* beginDoc,
1295 bool collectComments =
true);
1299 bool parse(std::istream& is,
Value& root,
bool collectComments =
true);
1311 std::
string getFormatedErrorMessages() const;
1321 std::
string getFormattedErrorMessages() const;
1338 bool pushError(const
Value& value, const std::
string& message);
1347 bool pushError(const
Value& value, const std::
string& message, const
Value& extra);
1357 tokenEndOfStream = 0,
1389 bool readToken(
Token& token);
1391 bool match(
Location pattern,
int patternLength);
1393 bool readCStyleComment();
1394 bool readCppStyleComment();
1398 bool readObject(
Token& token);
1399 bool readArray(
Token& token);
1400 bool decodeNumber(
Token& token);
1401 bool decodeNumber(
Token& token,
Value& decoded);
1402 bool decodeString(
Token& token);
1403 bool decodeString(
Token& token, std::string& decoded);
1404 bool decodeDouble(
Token& token);
1405 bool decodeDouble(
Token& token,
Value& decoded);
1406 bool decodeUnicodeCodePoint(
Token& token,
1409 unsigned int& unicode);
1410 bool decodeUnicodeEscapeSequence(
Token& token,
1413 unsigned int& unicode);
1414 bool addError(
const std::string& message,
Token& token,
Location extra = 0);
1415 bool recoverFromError(
TokenType skipUntilToken);
1416 bool addErrorAndRecover(
const std::string& message,
1419 void skipUntilSpace();
1420 Value& currentValue();
1423 getLocationLineAndColumn(
Location location,
int& line,
int& column)
const;
1424 std::string getLocationLineAndColumn(
Location location)
const;
1426 void skipCommentTokens(
Token& token);
1465 char const* beginDoc,
char const* endDoc,
1466 Value* root, std::string* errs) = 0;
1474 virtual CharReader* newCharReader()
const = 0;
1541 Value& operator[](std::string key);
1564 Value* root, std::string* errs);
1594 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1595 #pragma warning(pop)
1596 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1598 #endif // CPPTL_JSON_READER_H_INCLUDED
1618 #ifndef JSON_WRITER_H_INCLUDED
1619 #define JSON_WRITER_H_INCLUDED
1621 #if !defined(JSON_IS_AMALGAMATION)
1623 #endif // if !defined(JSON_IS_AMALGAMATION)
1630 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1631 #pragma warning(push)
1632 #pragma warning(disable : 4251)
1633 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1664 virtual int write(
Value const& root, std::ostream* sout) = 0;
1736 Value& operator[](std::string key);
1753 virtual std::string write(
const Value& root) = 0;
1771 void enableYAMLCompatibility();
1778 void dropNullPlaceholders();
1780 void omitEndingLineFeed();
1783 virtual std::string write(
const Value& root);
1786 void writeValue(
const Value& value);
1828 virtual std::string write(
const Value& root);
1831 void writeValue(
const Value& value);
1832 void writeArrayValue(
const Value& value);
1833 bool isMultineArray(
const Value& value);
1834 void pushValue(
const std::string& value);
1836 void writeWithIndent(
const std::string& value);
1839 void writeCommentBeforeValue(
const Value& root);
1840 void writeCommentAfterValueOnSameLine(
const Value& root);
1841 bool hasCommentForValue(
const Value& value);
1842 static std::string
normalizeEOL(
const std::string& text);
1892 void write(std::ostream& out,
const Value& root);
1895 void writeValue(
const Value& value);
1896 void writeArrayValue(
const Value& value);
1897 bool isMultineArray(
const Value& value);
1898 void pushValue(
const std::string& value);
1900 void writeWithIndent(
const std::string& value);
1903 void writeCommentBeforeValue(
const Value& root);
1904 void writeCommentAfterValueOnSameLine(
const Value& root);
1905 bool hasCommentForValue(
const Value& value);
1906 static std::string
normalizeEOL(
const std::string& text);
1915 bool addChildValues_ : 1;
1919 #if defined(JSON_HAS_INT64)
1922 #endif // if defined(JSON_HAS_INT64)
1935 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1936 #pragma warning(pop)
1937 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1939 #endif // JSON_WRITER_H_INCLUDED
1959 #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
1960 #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
1965 #if !defined(JSON_IS_AMALGAMATION)
1967 #endif // if !defined(JSON_IS_AMALGAMATION)
1973 #if JSON_USE_EXCEPTION
1976 # define JSON_ASSERT(condition) \
1977 {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
1979 # define JSON_FAIL_MESSAGE(message) \
1981 std::ostringstream oss; oss << message; \
1982 Json::throwLogicError(oss.str()); \
1986 #else // JSON_USE_EXCEPTION
1988 # define JSON_ASSERT(condition) assert(condition)
1992 # define JSON_FAIL_MESSAGE(message) \
1994 std::ostringstream oss; oss << message; \
1995 assert(false && oss.str().c_str()); \
2002 #define JSON_ASSERT_MESSAGE(condition, message) \
2003 if (!(condition)) { \
2004 JSON_FAIL_MESSAGE(message); \
2007 #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
2017 #endif //ifndef JSON_AMALGATED_H_INCLUDED
std::vector< std::string > ChildValues
std::vector< std::string > Members
bool allowNumericKeys_
true if numeric object key are allowed. Default: false.
std::string JSON_API valueToQuotedString(const char *value)
JSON_API std::ostream & operator<<(std::ostream &, const Value &root)
Output using the StyledStreamWriter.
bool allowComments_
true if comments are allowed. Default: true.
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
Json::LargestInt LargestInt
bool dropNullPlaceholders_
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
pointer operator->() const
std::string indentString_
Experimental and untested: represents an element of the "path" to access a node.
Json::ArrayIndex ArrayIndex
std::string commentsBefore_
Lightweight wrapper to tag static string.
ValueConstIterator const_iterator
bool yamlCompatiblityEnabled_
std::stack< Value * > Nodes
std::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...
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
const char * c_str() const
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
a comment placed on the line before a value
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
std::deque< ErrorInfo > Errors
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
difference_type operator-(const SelfType &other) const
Outputs a Value in JSON format without formatting (not human friendly).
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
std::string JSON_API valueToString(Int value)
reference operator*() const
difference_type computeDistance(const SelfType &other) const
void throwLogicError(std::string const &msg)
used internally
std::map< CZString, Value > ObjectValues
An error tagged with where in the JSON text it was encountered.
Abstract class for writers.
ValueConstIterator SelfType
object value (collection of name/value pairs).
Json::LargestUInt LargestUInt
Build a CharReader implementation.
void swap(Value &other)
Swap everything.
ValueType
Type of the value held by a Value object.
static const Value & null
We regret this reference to a global instance; prefer the simpler Value().
ValueIteratorBase SelfType
a comment just after a value on the same line
JSON_API std::istream & operator>>(std::istream &, Value &)
Read from 'sin' into 'root'.
base class for Value iterators.
bool operator==(const SelfType &other) const
std::string indentString_
std::vector< const PathArgument * > InArgs
pointer operator->() const
bool operator!=(const SelfType &other) const
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
bool JSON_API parseFromStream(CharReader::Factory const &, std::istream &, Value *root, std::string *errs)
bool allowDroppedNullPlaceholders_
true if dropped null placeholders are allowed. Default: false.
A simple abstract factory.
StaticString(const char *czstring)
Unserialize a JSON document into a Value.
unsigned long long int UInt64
std::vector< PathArgument > Args
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
std::bidirectional_iterator_tag iterator_category
Build a StreamWriter implementation.
Iterator for object and array value.
reference operator*() const
std::vector< std::string > ChildValues
Writes a Value in JSON format in a human friendly way.
Experimental and untested: represents a "path" to access a node.
const iterator for object and array value.
#define JSONCPP_DEPRECATED(message)
array value (ordered list)
static std::string normalizeEOL(Reader::Location begin, Reader::Location end)
void throwRuntimeError(std::string const &msg)
used internally
static const Value & nullRef