75#ifndef JSON_AMALGATED_H_INCLUDED
76# define JSON_AMALGATED_H_INCLUDED
79#define JSON_IS_AMALGAMATION
87#ifndef JSON_VERSION_H_INCLUDED
88# define JSON_VERSION_H_INCLUDED
90# define JSONCPP_VERSION_STRING "0.10.6"
91# define JSONCPP_VERSION_MAJOR 0
92# define JSONCPP_VERSION_MINOR 10
93# define JSONCPP_VERSION_PATCH 6
94# define JSONCPP_VERSION_QUALIFIER
95# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
117#ifndef JSON_CONFIG_H_INCLUDED
118#define JSON_CONFIG_H_INCLUDED
132#ifndef JSON_USE_EXCEPTION
133#define JSON_USE_EXCEPTION 1
142#include <cpptl/config.h>
143#ifndef JSON_USE_CPPTL
144#define JSON_USE_CPPTL 1
149#define JSON_API CPPTL_API
150#elif defined(JSON_DLL_BUILD)
152#define JSON_API __declspec(dllexport)
153#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
155#elif defined(JSON_DLL)
157#define JSON_API __declspec(dllimport)
158#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
161#if !defined(JSON_API)
165#if !defined(JSON_HAS_UNIQUE_PTR)
166#if __cplusplus >= 201103L
167#define JSON_HAS_UNIQUE_PTR (1)
168#elif _MSC_VER >= 1600
169#define JSON_HAS_UNIQUE_PTR (1)
171#define JSON_HAS_UNIQUE_PTR (0)
180#if defined(_MSC_VER) && _MSC_VER <= 1200
183#define JSON_USE_INT64_DOUBLE_CONVERSION 1
188#pragma warning(disable : 4786)
191#if defined(_MSC_VER) && _MSC_VER >= 1500
193#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
194#elif defined(__clang__) && defined(__has_feature)
195#if __has_feature(attribute_deprecated_with_message)
196#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
198#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
199#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
200#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
201#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
204#if !defined(JSONCPP_DEPRECATED)
205#define JSONCPP_DEPRECATED(message)
210typedef unsigned int UInt;
211#if defined(JSON_NO_INT64)
212typedef int LargestInt;
213typedef unsigned int LargestUInt;
218typedef __int64 Int64;
219typedef unsigned __int64 UInt64;
221typedef long long int Int64;
222typedef unsigned long long int UInt64;
224typedef Int64 LargestInt;
225typedef UInt64 LargestUInt;
226#define JSON_HAS_INT64
250#ifndef JSON_FORWARDS_H_INCLUDED
251#define JSON_FORWARDS_H_INCLUDED
253#if !defined(JSON_IS_AMALGAMATION)
270typedef unsigned int ArrayIndex;
275class ValueIteratorBase;
277class ValueConstIterator;
301#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
302#define CPPTL_JSON_FEATURES_H_INCLUDED
304#if !defined(JSON_IS_AMALGAMATION)
366#ifndef CPPTL_JSON_H_INCLUDED
367#define CPPTL_JSON_H_INCLUDED
369#if !defined(JSON_IS_AMALGAMATION)
376#ifndef JSON_USE_CPPTL_SMALLMAP
379#include <cpptl/smallmap.h>
382#include <cpptl/forwards.h>
387#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
389#pragma warning(disable : 4251)
395#if !defined(JSONCPP_NORETURN)
396# if defined(_MSC_VER)
397# define JSONCPP_NORETURN __declspec(noreturn)
398# elif defined(__GNUC__)
399# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
401# define JSONCPP_NORETURN
417 virtual char const* what()
const throw();
419 void operator = (
const Exception&) =
delete;
420 std::string
const msg_;
492 explicit StaticString(
const char* czstring) : c_str_(czstring) {}
494 operator const char*()
const {
return c_str_; }
496 const char* c_str()
const {
return c_str_; }
539 typedef std::vector<std::string> Members;
542 typedef Json::UInt UInt;
543 typedef Json::Int Int;
544#if defined(JSON_HAS_INT64)
545 typedef Json::UInt64 UInt64;
546 typedef Json::Int64 Int64;
548 typedef Json::LargestInt LargestInt;
549 typedef Json::LargestUInt LargestUInt;
550 typedef Json::ArrayIndex ArrayIndex;
552 static const Value& nullRef;
553#if !defined(__ARMEL__)
571#if defined(JSON_HAS_INT64)
586#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
589 enum DuplicationPolicy {
594 CZString(ArrayIndex index);
595 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
596 CZString(CZString
const& other);
598 CZString& operator=(CZString other);
599 bool operator<(CZString
const& other)
const;
600 bool operator==(CZString
const& other)
const;
601 ArrayIndex index()
const;
603 char const* data()
const;
604 unsigned length()
const;
605 bool isStaticString()
const;
608 void swap(CZString& other);
610 struct StringStorage {
612 unsigned length_: 30;
618 StringStorage storage_;
623#ifndef JSON_USE_CPPTL_SMALLMAP
624 typedef std::map<CZString, Value> ObjectValues;
626 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
649#if defined(JSON_HAS_INT64)
654 Value(
const char* value);
655 Value(
const char* begin,
const char* end);
672 Value(
const std::string& value);
674 Value(
const CppTL::ConstString& value);
685 void swap(
Value& other);
687 void swapPayload(
Value& other);
692 bool operator<(
const Value& other)
const;
693 bool operator<=(
const Value& other)
const;
694 bool operator>=(
const Value& other)
const;
695 bool operator>(
const Value& other)
const;
696 bool operator==(
const Value& other)
const;
697 bool operator!=(
const Value& other)
const;
698 int compare(
const Value& other)
const;
700 const char* asCString()
const;
701 std::string asString()
const;
706 char const** begin,
char const** end)
const;
708 CppTL::ConstString asConstString()
const;
712#if defined(JSON_HAS_INT64)
713 Int64 asInt64()
const;
714 UInt64 asUInt64()
const;
716 LargestInt asLargestInt()
const;
717 LargestUInt asLargestUInt()
const;
718 float asFloat()
const;
719 double asDouble()
const;
725 bool isInt64()
const;
727 bool isUInt64()
const;
728 bool isIntegral()
const;
729 bool isDouble()
const;
730 bool isNumeric()
const;
731 bool isString()
const;
732 bool isArray()
const;
733 bool isObject()
const;
735 bool isConvertibleTo(
ValueType other)
const;
738 ArrayIndex size()
const;
745 bool operator!()
const;
757 void resize(ArrayIndex size);
765 Value& operator[](ArrayIndex index);
773 Value& operator[](
int index);
778 const Value& operator[](ArrayIndex index)
const;
783 const Value& operator[](
int index)
const;
788 Value get(ArrayIndex index,
const Value& defaultValue)
const;
790 bool isValidIndex(ArrayIndex index)
const;
799 Value& operator[](
const char* key);
802 const Value& operator[](
const char* key)
const;
805 Value& operator[](
const std::string& key);
809 const Value& operator[](
const std::string& key)
const;
825 Value& operator[](
const CppTL::ConstString& key);
828 const Value& operator[](
const CppTL::ConstString& key)
const;
832 Value get(
const char* key,
const Value& defaultValue)
const;
836 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
840 Value get(
const std::string& key,
const Value& defaultValue)
const;
844 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
849 Value const* find(
char const* begin,
char const* end)
const;
861 Value removeMember(
const char* key);
865 Value removeMember(
const std::string& key);
868 bool removeMember(
const char* key,
Value* removed);
875 bool removeMember(std::string
const& key,
Value* removed);
877 bool removeMember(
const char* begin,
const char* end,
Value* removed);
884 bool removeIndex(ArrayIndex i,
Value* removed);
888 bool isMember(
const char* key)
const;
891 bool isMember(
const std::string& key)
const;
893 bool isMember(
const char* begin,
const char* end)
const;
896 bool isMember(
const CppTL::ConstString& key)
const;
904 Members getMemberNames()
const;
912 JSONCPP_DEPRECATED(
"Use setComment(std::string const&) instead.")
915 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
922 std::
string toStyledString() const;
931 size_t order()
const {
return order_; }
934 void initBasic(
ValueType type,
bool allocated =
false);
936 Value& resolveReference(
const char* key);
937 Value& resolveReference(
const char* key,
const char* end);
943 void setComment(
const char* text,
size_t len);
966 unsigned int allocated_ : 1;
968 CommentInfo* comments_;
1010 Path(
const std::string& path,
1017 const Value& resolve(
const Value& root)
const;
1024 typedef std::vector<const PathArgument*> InArgs;
1025 typedef std::vector<PathArgument> Args;
1027 void makePath(
const std::string& path,
const InArgs& in);
1028 void addPathInArg(
const std::string& path,
1030 InArgs::const_iterator& itInArg,
1031 PathArgument::Kind kind);
1032 void invalidPath(
const std::string& path,
int location);
1042 typedef std::bidirectional_iterator_tag iterator_category;
1043 typedef unsigned int size_t;
1044 typedef int difference_type;
1047 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
1049 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
1051 difference_type operator-(
const SelfType& other)
const {
1052 return other.computeDistance(*
this);
1065 std::string name()
const;
1070 JSONCPP_DEPRECATED(
"Use `key = name();` instead.")
1071 char const* memberName()
const;
1075 char const* memberName(
char const** end)
const;
1078 Value& deref()
const;
1084 difference_type computeDistance(
const SelfType& other)
const;
1086 bool isEqual(
const SelfType& other)
const;
1091 Value::ObjectValues::iterator current_;
1147 reference operator*()
const {
return deref(); }
1149 pointer operator->()
const {
return &deref(); }
1159 typedef unsigned int size_t;
1160 typedef int difference_type;
1172 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
1198 reference operator*()
const {
return deref(); }
1200 pointer operator->()
const {
return &deref(); }
1213#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1237#ifndef CPPTL_JSON_READER_H_INCLUDED
1238#define CPPTL_JSON_READER_H_INCLUDED
1240#if !defined(JSON_IS_AMALGAMATION)
1241#include "features.h"
1252#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1253#pragma warning(push)
1254#pragma warning(disable : 4251)
1267 typedef const Char* Location;
1294 parse(
const std::string& document,
Value& root,
bool collectComments =
true);
1314 bool parse(
const char* beginDoc,
1317 bool collectComments =
true);
1321 bool parse(std::istream& is,
Value& root,
bool collectComments =
true);
1332 JSONCPP_DEPRECATED(
"Use getFormattedErrorMessages() instead.")
1333 std::string getFormatedErrorMessages()
const;
1343 std::string getFormattedErrorMessages()
const;
1347 tokenEndOfStream = 0,
1357 tokenArraySeparator,
1358 tokenMemberSeparator,
1373 std::string message_;
1377 typedef std::deque<ErrorInfo> Errors;
1379 bool readToken(Token& token);
1381 bool match(Location pattern,
int patternLength);
1383 bool readCStyleComment();
1384 bool readCppStyleComment();
1388 bool readObject(Token& token);
1389 bool readArray(Token& token);
1390 bool decodeNumber(Token& token);
1391 bool decodeNumber(Token& token,
Value& decoded);
1392 bool decodeString(Token& token);
1393 bool decodeString(Token& token, std::string& decoded);
1394 bool decodeDouble(Token& token);
1395 bool decodeDouble(Token& token,
Value& decoded);
1396 bool decodeUnicodeCodePoint(Token& token,
1399 unsigned int& unicode);
1400 bool decodeUnicodeEscapeSequence(Token& token,
1403 unsigned int& unicode);
1404 bool addError(
const std::string& message, Token& token, Location extra = 0);
1405 bool recoverFromError(TokenType skipUntilToken);
1406 bool addErrorAndRecover(
const std::string& message,
1408 TokenType skipUntilToken);
1409 void skipUntilSpace();
1410 Value& currentValue();
1413 getLocationLineAndColumn(Location location,
int& line,
int& column)
const;
1414 std::string getLocationLineAndColumn(Location location)
const;
1416 void skipCommentTokens(Token& token);
1418 typedef std::stack<Value*> Nodes;
1421 std::string document_;
1425 Location lastValueEnd_;
1427 std::string commentsBefore_;
1429 bool collectComments_;
1455 char const* beginDoc,
char const* endDoc,
1456 Value* root, std::string* errs) = 0;
1534 Value& operator[](std::string key);
1557 Value* root, std::string* errs);
1587#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1611#ifndef JSON_WRITER_H_INCLUDED
1612#define JSON_WRITER_H_INCLUDED
1614#if !defined(JSON_IS_AMALGAMATION)
1623#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1624#pragma warning(push)
1625#pragma warning(disable : 4251)
1647 std::ostream* sout_;
1733 Value& operator[](std::string key);
1750 virtual std::string write(
const Value& root) = 0;
1768 void enableYAMLCompatibility();
1771 virtual std::string write(
const Value& root);
1774 void writeValue(
const Value& value);
1776 std::string document_;
1777 bool yamlCompatiblityEnabled_;
1814 virtual std::string write(
const Value& root);
1817 void writeValue(
const Value& value);
1818 void writeArrayValue(
const Value& value);
1819 bool isMultineArray(
const Value& value);
1820 void pushValue(
const std::string& value);
1822 void writeWithIndent(
const std::string& value);
1825 void writeCommentBeforeValue(
const Value& root);
1826 void writeCommentAfterValueOnSameLine(
const Value& root);
1827 bool hasCommentForValue(
const Value& value);
1828 static std::string normalizeEOL(
const std::string& text);
1830 typedef std::vector<std::string> ChildValues;
1832 ChildValues childValues_;
1833 std::string document_;
1834 std::string indentString_;
1837 bool addChildValues_;
1878 void write(std::ostream& out,
const Value& root);
1881 void writeValue(
const Value& value);
1882 void writeArrayValue(
const Value& value);
1883 bool isMultineArray(
const Value& value);
1884 void pushValue(
const std::string& value);
1886 void writeWithIndent(
const std::string& value);
1889 void writeCommentBeforeValue(
const Value& root);
1890 void writeCommentAfterValueOnSameLine(
const Value& root);
1891 bool hasCommentForValue(
const Value& value);
1892 static std::string normalizeEOL(
const std::string& text);
1894 typedef std::vector<std::string> ChildValues;
1896 ChildValues childValues_;
1897 std::ostream* document_;
1898 std::string indentString_;
1900 std::string indentation_;
1901 bool addChildValues_ : 1;
1905#if defined(JSON_HAS_INT64)
1906std::string JSON_API valueToString(Int value);
1907std::string JSON_API valueToString(UInt value);
1909std::string JSON_API valueToString(LargestInt value);
1910std::string JSON_API valueToString(LargestUInt value);
1911std::string JSON_API valueToString(
double value);
1912std::string JSON_API valueToString(
bool value);
1913std::string JSON_API valueToQuotedString(
const char* value);
1921#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1945#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
1946#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
1951#if !defined(JSON_IS_AMALGAMATION)
1959#if JSON_USE_EXCEPTION
1962# define JSON_ASSERT(condition) \
1963 {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
1965# define JSON_FAIL_MESSAGE(message) \
1967 std::ostringstream oss; oss << message; \
1968 Json::throwLogicError(oss.str()); \
1974# define JSON_ASSERT(condition) assert(condition)
1978# define JSON_FAIL_MESSAGE(message) \
1980 std::ostringstream oss; oss << message; \
1981 assert(false && oss.str().c_str()); \
1988#define JSON_ASSERT_MESSAGE(condition, message) \
1989 if (!(condition)) { \
1990 JSON_FAIL_MESSAGE(message); \
Build a CharReader implementation.
Definition json.h:1480
Json::Value settings_
Definition json.h:1520
virtual CharReader * newCharReader() const =0
Allocate a CharReader via operator new().
virtual bool parse(char const *beginDoc, char const *endDoc, Value *root, std::string *errs)=0
Read a Value from a JSON document. The document must be a UTF-8 encoded string containing the documen...
Outputs a Value in JSON format without formatting (not human friendly).
Definition json.h:1762
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition json.h:314
bool strictRoot_
Definition json.h:341
bool allowComments_
true if comments are allowed. Default: true.
Definition json.h:337
Experimental and untested: represents an element of the "path" to access a node.
Definition json.h:977
Experimental and untested: represents a "path" to access a node.
Definition json.h:1008
Unserialize a JSON document into a Value.
Definition json.h:1264
Lightweight wrapper to tag static string.
Definition json.h:490
Build a StreamWriter implementation.
Definition json.h:1692
Json::Value settings_
Definition json.h:1717
A simple abstract factory.
Definition json.h:1661
virtual StreamWriter * newStreamWriter() const =0
Allocate a CharReader via operator new().
virtual int write(Value const &root, std::ostream *sout)=0
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string.
Definition json.h:1866
Writes a Value in JSON format in a human friendly way.
Definition json.h:1804
const iterator for object and array value.
Definition json.h:1105
base class for Value iterators.
Definition json.h:1040
Iterator for object and array value.
Definition json.h:1154
Represents a JSON value.
Definition json.h:536
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition json.h:575
static const Value null
Definition json.h:555
Value const * demand(char const *begin, char const *end)
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition json.h:565
static const Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
Definition json.h:573
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition json.h:560
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition json.h:562
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition json.h:567
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition json.h:569
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition json.h:577
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
Definition json.h:558
Abstract class for writers.
Definition json.h:1746
JSON (JavaScript Object Notation).
Definition json-forwards.h:182
JSON_API std::istream & operator>>(std::istream &, Value &)
Read from 'sin' into 'root'.
Definition jsoncpp.cpp:2011
CommentPlacement
Definition json.h:463
@ commentAfterOnSameLine
a comment just after a value on the same line
Definition json.h:465
@ commentBefore
a comment placed on the line before a value
Definition json.h:464
@ numberOfCommentPlacement
root value)
Definition json.h:468
@ commentAfter
Definition json.h:466
ValueType
Type of the value held by a Value object.
Definition json.h:452
@ booleanValue
bool value
Definition json.h:458
@ nullValue
'null' value
Definition json.h:453
@ stringValue
UTF-8 string value.
Definition json.h:457
@ realValue
double value
Definition json.h:456
@ arrayValue
array value (ordered list)
Definition json.h:459
@ intValue
signed integer value
Definition json.h:454
@ objectValue
object value (collection of name/value pairs).
Definition json.h:460
@ uintValue
unsigned integer value
Definition json.h:455
JSON_API std::ostream & operator<<(std::ostream &, const Value &root)
Output using the StyledStreamWriter.
Definition jsoncpp.cpp:4950
bool JSON_API parseFromStream(CharReader::Factory const &, std::istream &, Value *root, std::string *errs)
Definition jsoncpp.cpp:1997
JSONCPP_NORETURN void throwRuntimeError(std::string const &msg)
used internally
Definition jsoncpp.cpp:2386
JSONCPP_NORETURN void throwLogicError(std::string const &msg)
used internally
Definition jsoncpp.cpp:2390
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...
Definition jsoncpp.cpp:4943