71 #ifndef JSON_AMALGATED_H_INCLUDED 72 #define JSON_AMALGATED_H_INCLUDED 73 #define JSON_IS_AMALGATED 86 #ifndef JSON_CONFIG_H_INCLUDED 87 #define JSON_CONFIG_H_INCLUDED 109 #define JSON_USE_EXCEPTION 1 117 #include <cpptl/config.h> 118 #ifndef JSON_USE_CPPTL 119 #define JSON_USE_CPPTL 1 124 #define JSON_API CPPTL_API 125 #elif defined(JSON_DLL_BUILD) 126 #define JSON_API __declspec(dllexport) 127 #elif defined(JSON_DLL) 128 #define JSON_API __declspec(dllimport) 137 #if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6 140 #define JSON_USE_INT64_DOUBLE_CONVERSION 1 141 #endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6 143 #if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008 144 #define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) 148 #if !defined(JSONCPP_DEPRECATED) 149 #define JSONCPP_DEPRECATED(message) 150 #endif // if !defined(JSONCPP_DEPRECATED) 155 typedef unsigned int UInt;
156 #if defined(JSON_NO_INT64) 157 typedef int LargestInt;
158 typedef unsigned int LargestUInt;
159 #undef JSON_HAS_INT64 160 #else // if defined(JSON_NO_INT64) 162 #if defined(_MSC_VER) // Microsoft Visual Studio 163 typedef __int64 Int64;
164 typedef unsigned __int64 UInt64;
165 #else // if defined(_MSC_VER) // Other platforms, use long long 166 typedef long long int Int64;
167 typedef unsigned long long int UInt64;
168 #endif // if defined(_MSC_VER) 169 typedef Int64 LargestInt;
170 typedef UInt64 LargestUInt;
171 #define JSON_HAS_INT64 172 #endif // if defined(JSON_NO_INT64) 175 #endif // JSON_CONFIG_H_INCLUDED 190 #ifndef JSON_FORWARDS_H_INCLUDED 191 #define JSON_FORWARDS_H_INCLUDED 193 #if !defined(JSON_IS_AMALGATED) 195 #endif // if !defined(JSON_IS_AMALGATED) 210 typedef unsigned int ArrayIndex;
218 #ifdef JSON_VALUE_USE_INTERNAL_MAP 223 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 227 #endif // JSON_FORWARDS_H_INCLUDED 242 #ifndef CPPTL_JSON_FEATURES_H_INCLUDED 243 #define CPPTL_JSON_FEATURES_H_INCLUDED 245 #if !defined(JSON_IS_AMALGATED) 246 #include "forwards.h" 247 #endif // if !defined(JSON_IS_AMALGATED) 285 #endif // CPPTL_JSON_FEATURES_H_INCLUDED 300 #ifndef CPPTL_JSON_H_INCLUDED 301 #define CPPTL_JSON_H_INCLUDED 303 #if !defined(JSON_IS_AMALGATED) 304 #include "forwards.h" 305 #endif // if !defined(JSON_IS_AMALGATED) 309 #ifndef JSON_USE_CPPTL_SMALLMAP 312 #include <cpptl/smallmap.h> 314 #ifdef JSON_USE_CPPTL 315 #include <cpptl/forwards.h> 341 numberOfCommentPlacement
371 operator const char *()
const {
return str_; }
372 const char *c_str()
const {
return str_; }
407 #ifdef JSON_VALUE_USE_INTERNAL_MAP 412 typedef std::vector<std::string> Members;
415 typedef Json::UInt UInt;
416 typedef Json::Int Int;
417 #if defined(JSON_HAS_INT64) 418 typedef Json::UInt64 UInt64;
419 typedef Json::Int64 Int64;
420 #endif // defined(JSON_HAS_INT64) 421 typedef Json::LargestInt LargestInt;
422 typedef Json::LargestUInt LargestUInt;
423 typedef Json::ArrayIndex ArrayIndex;
425 static const Value null;
448 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 449 #ifndef JSON_VALUE_USE_INTERNAL_MAP 453 enum DuplicationPolicy
459 CZString(ArrayIndex index);
460 CZString(
const char *cstr, DuplicationPolicy allocate);
461 CZString(
const CZString &other);
463 CZString &operator=(
const CZString &other);
464 bool operator<(
const CZString &other)
const;
465 bool operator==(
const CZString &other)
const;
466 ArrayIndex index()
const;
467 const char *c_str()
const;
468 bool isStaticString()
const;
471 void swap(CZString &other);
477 #ifndef JSON_USE_CPPTL_SMALLMAP 478 typedef std::map<CZString, Value> ObjectValues;
480 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
481 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 482 #endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 483 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 504 #if defined(JSON_HAS_INT64) 507 #endif // if defined(JSON_HAS_INT64) 509 Value(
const char *value);
510 Value(
const char *beginValue,
const char *endValue);
522 Value(
const std::string &value);
523 #ifdef JSON_USE_CPPTL 524 Value(
const CppTL::ConstString &value);
534 void swap(
Value &other);
538 bool operator<(
const Value &other)
const;
539 bool operator<=(
const Value &other)
const;
540 bool operator>=(
const Value &other)
const;
541 bool operator>(
const Value &other)
const;
543 bool operator==(
const Value &other)
const;
544 bool operator!=(
const Value &other)
const;
546 int compare(
const Value &other)
const;
548 const char *asCString()
const;
549 std::string asString()
const;
550 #ifdef JSON_USE_CPPTL 551 CppTL::ConstString asConstString()
const;
555 Int64 asInt64()
const;
556 UInt64 asUInt64()
const;
557 LargestInt asLargestInt()
const;
558 LargestUInt asLargestUInt()
const;
559 float asFloat()
const;
560 double asDouble()
const;
567 bool isIntegral()
const;
568 bool isDouble()
const;
569 bool isNumeric()
const;
570 bool isString()
const;
571 bool isArray()
const;
572 bool isObject()
const;
574 bool isConvertibleTo(
ValueType other)
const;
577 ArrayIndex size()
const;
584 bool operator!()
const;
596 void resize(ArrayIndex size);
603 Value &operator[](ArrayIndex index);
610 Value &operator[](
int index);
615 const Value &operator[](ArrayIndex index)
const;
620 const Value &operator[](
int index)
const;
624 Value get(ArrayIndex index,
const Value &defaultValue)
const;
626 bool isValidIndex(ArrayIndex index)
const;
633 Value &operator[](
const char *key);
635 const Value &operator[](
const char *key)
const;
637 Value &operator[](
const std::string &key);
639 const Value &operator[](
const std::string &key)
const;
652 #ifdef JSON_USE_CPPTL 653 Value &operator[](
const CppTL::ConstString &key);
656 const Value &operator[](
const CppTL::ConstString &key)
const;
658 Value get(
const char *key,
const Value &defaultValue)
const;
661 Value get(
const std::string &key,
const Value &defaultValue)
const;
662 #ifdef JSON_USE_CPPTL 663 Value get(
const CppTL::ConstString &key,
const Value &defaultValue)
const;
666 Value removeMember(
const char *key);
674 Value removeMember(
const std::string &key);
677 bool isMember(
const char *key)
const;
679 bool isMember(
const std::string &key)
const;
680 #ifdef JSON_USE_CPPTL 681 bool isMember(
const CppTL::ConstString &key)
const;
690 Members getMemberNames()
const;
705 std::string toStyledString()
const;
707 const_iterator begin()
const;
708 const_iterator end()
const;
714 Value &resolveReference(
const char *key,
bool isStatic);
716 #ifdef JSON_VALUE_USE_INTERNAL_MAP 717 inline bool isItemAvailable()
const {
return itemIsUsed_ == 0; }
718 inline void setItemUsed(
bool isUsed =
true) { itemIsUsed_ = isUsed ? 1 : 0; }
719 inline bool isMemberNameStatic()
const {
return memberNameIsStatic_ == 0; }
720 inline void setMemberNameIsStatic(
bool isStatic) { memberNameIsStatic_ = isStatic ? 1 : 0; }
721 #endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 729 void setComment(
const char *text);
750 #ifdef JSON_VALUE_USE_INTERNAL_MAP 759 #ifdef JSON_VALUE_USE_INTERNAL_MAP 760 unsigned int itemIsUsed_ : 1;
761 int memberNameIsStatic_ : 1;
763 CommentInfo *comments_;
804 Path(
const std::string &path,
811 const Value &resolve(
const Value &root)
const;
817 typedef std::vector<const PathArgument *> InArgs;
818 typedef std::vector<PathArgument> Args;
820 void makePath(
const std::string &path,
const InArgs &in);
821 void addPathInArg(
const std::string &path,
823 InArgs::const_iterator &itInArg,
824 PathArgument::Kind kind);
825 void invalidPath(
const std::string &path,
int location);
830 #ifdef JSON_VALUE_USE_INTERNAL_MAP 908 Value items_[itemPerLink];
909 char *keys_[itemPerLink];
932 typedef unsigned int HashKey;
933 typedef unsigned int BucketIndex;
935 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 947 BucketIndex itemIndex_;
948 BucketIndex bucketIndex_;
950 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 959 BucketIndex size()
const;
963 bool reserveDelta(BucketIndex growth);
965 bool reserve(BucketIndex newItemCount);
967 const Value *find(
const char *key)
const;
969 Value *find(
const char *key);
971 Value &resolveReference(
const char *key,
bool isStatic);
973 void remove(
const char *key);
975 void doActualRemove(
ValueInternalLink *link, BucketIndex index, BucketIndex bucketIndex);
981 Value &unsafeAdd(
const char *key,
bool isStatic, HashKey hashedKey);
983 HashKey hash(
const char *key)
const;
995 static const char *key(
const IteratorState &iterator,
bool &isStatic);
1002 BucketIndex bucketsSize_;
1003 BucketIndex itemCount_;
1027 typedef Value::ArrayIndex ArrayIndex;
1028 typedef unsigned int PageIndex;
1030 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 1035 , currentPageIndex_(0)
1036 , currentItemIndex_(0)
1040 Value **currentPageIndex_;
1041 unsigned int currentItemIndex_;
1043 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 1052 void resize(ArrayIndex newSize);
1054 Value &resolveReference(ArrayIndex index);
1056 Value *find(ArrayIndex index)
const;
1058 ArrayIndex size()
const;
1072 void makeIterator(
IteratorState &it, ArrayIndex index)
const;
1074 void makeIndexValid(ArrayIndex index);
1078 PageIndex pageCount_;
1158 virtual void reallocateArrayPageIndex(
Value **&indexes,
1159 ValueInternalArray::PageIndex &indexCount,
1160 ValueInternalArray::PageIndex minNewIndexCount) = 0;
1161 virtual void releaseArrayPageIndex(
Value **indexes, ValueInternalArray::PageIndex indexCount) = 0;
1162 virtual Value *allocateArrayPage() = 0;
1163 virtual void releaseArrayPage(
Value *value) = 0;
1165 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 1173 typedef unsigned int size_t;
1174 typedef int difference_type;
1178 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1185 bool operator==(
const SelfType &other)
const {
return isEqual(other); }
1186 bool operator!=(
const SelfType &other)
const {
return !isEqual(other); }
1187 difference_type operator-(
const SelfType &other)
const {
return computeDistance(other); }
1195 const char *memberName()
const;
1198 Value &deref()
const;
1204 difference_type computeDistance(
const SelfType &other)
const;
1206 bool isEqual(
const SelfType &other)
const;
1208 void copy(
const SelfType &other);
1211 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1212 Value::ObjectValues::iterator current_;
1233 typedef unsigned int size_t;
1234 typedef int difference_type;
1244 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1253 SelfType operator++(
int)
1255 SelfType temp(*
this);
1260 SelfType operator--(
int)
1262 SelfType temp(*
this);
1267 SelfType &operator--()
1273 SelfType &operator++()
1279 reference operator*()
const {
return deref(); }
1289 typedef unsigned int size_t;
1290 typedef int difference_type;
1302 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1303 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t);
1309 SelfType &operator=(
const SelfType &other);
1311 SelfType operator++(
int)
1313 SelfType temp(*
this);
1318 SelfType operator--(
int)
1320 SelfType temp(*
this);
1325 SelfType &operator--()
1331 SelfType &operator++()
1337 reference operator*()
const {
return deref(); }
1342 #endif // CPPTL_JSON_H_INCLUDED 1357 #ifndef CPPTL_JSON_READER_H_INCLUDED 1358 #define CPPTL_JSON_READER_H_INCLUDED 1360 #if !defined(JSON_IS_AMALGATED) 1361 #include "features.h" 1363 #endif // if !defined(JSON_IS_AMALGATED) 1378 typedef const Char *Location;
1400 bool parse(
const std::string &document,
Value &root,
bool collectComments =
true);
1414 bool parse(
const char *beginDoc,
const char *endDoc,
Value &root,
bool collectComments =
true);
1418 bool parse(std::istream &is,
Value &root,
bool collectComments =
true);
1426 JSONCPP_DEPRECATED(
"Use getFormattedErrorMessages instead")
1427 std::string getFormatedErrorMessages()
const;
1434 std::string getFormattedErrorMessages()
const;
1439 tokenEndOfStream = 0,
1449 tokenArraySeparator,
1450 tokenMemberSeparator,
1467 std::string message_;
1471 typedef std::deque<ErrorInfo> Errors;
1473 bool expectToken(TokenType type, Token &token,
const char *message);
1474 bool readToken(Token &token);
1476 bool match(Location pattern,
int patternLength);
1478 bool readCStyleComment();
1479 bool readCppStyleComment();
1483 bool readObject(Token &token);
1484 bool readArray(Token &token);
1485 bool decodeNumber(Token &token);
1486 bool decodeString(Token &token);
1487 bool decodeString(Token &token, std::string &decoded);
1488 bool decodeDouble(Token &token);
1489 bool decodeUnicodeCodePoint(Token &token, Location ¤t, Location end,
unsigned int &unicode);
1490 bool decodeUnicodeEscapeSequence(Token &token, Location ¤t, Location end,
unsigned int &unicode);
1491 bool addError(
const std::string &message, Token &token, Location extra = 0);
1492 bool recoverFromError(TokenType skipUntilToken);
1493 bool addErrorAndRecover(
const std::string &message, Token &token, TokenType skipUntilToken);
1494 void skipUntilSpace();
1495 Value ¤tValue();
1497 void getLocationLineAndColumn(Location location,
int &line,
int &column)
const;
1498 std::string getLocationLineAndColumn(Location location)
const;
1500 void skipCommentTokens(Token &token);
1502 typedef std::stack<Value *> Nodes;
1505 std::string document_;
1509 Location lastValueEnd_;
1511 std::string commentsBefore_;
1513 bool collectComments_;
1544 #endif // CPPTL_JSON_READER_H_INCLUDED 1559 #ifndef JSON_WRITER_H_INCLUDED 1560 #define JSON_WRITER_H_INCLUDED 1562 #if !defined(JSON_IS_AMALGATED) 1564 #endif // if !defined(JSON_IS_AMALGATED) 1580 virtual std::string write(
const Value &root) = 0;
1594 void enableYAMLCompatibility();
1597 virtual std::string write(
const Value &root);
1600 void writeValue(
const Value &value);
1602 std::string document_;
1603 bool yamlCompatiblityEnabled_;
1634 virtual std::string write(
const Value &root);
1637 void writeValue(
const Value &value);
1638 void writeArrayValue(
const Value &value);
1639 bool isMultineArray(
const Value &value);
1640 void pushValue(
const std::string &value);
1642 void writeWithIndent(
const std::string &value);
1645 void writeCommentBeforeValue(
const Value &root);
1646 void writeCommentAfterValueOnSameLine(
const Value &root);
1647 bool hasCommentForValue(
const Value &value);
1648 static std::string normalizeEOL(
const std::string &text);
1650 typedef std::vector<std::string> ChildValues;
1652 ChildValues childValues_;
1653 std::string document_;
1654 std::string indentString_;
1657 bool addChildValues_;
1691 void write(std::ostream &out,
const Value &root);
1694 void writeValue(
const Value &value);
1695 void writeArrayValue(
const Value &value);
1696 bool isMultineArray(
const Value &value);
1697 void pushValue(
const std::string &value);
1699 void writeWithIndent(
const std::string &value);
1702 void writeCommentBeforeValue(
const Value &root);
1703 void writeCommentAfterValueOnSameLine(
const Value &root);
1704 bool hasCommentForValue(
const Value &value);
1705 static std::string normalizeEOL(
const std::string &text);
1707 typedef std::vector<std::string> ChildValues;
1709 ChildValues childValues_;
1710 std::ostream *document_;
1711 std::string indentString_;
1713 std::string indentation_;
1714 bool addChildValues_;
1717 #if defined(JSON_HAS_INT64) 1718 std::string JSON_API valueToString(Int value);
1719 std::string JSON_API valueToString(UInt value);
1720 #endif // if defined(JSON_HAS_INT64) 1721 std::string JSON_API valueToString(LargestInt value);
1722 std::string JSON_API valueToString(LargestUInt value);
1723 std::string JSON_API valueToString(
double value);
1724 std::string JSON_API valueToString(
bool value);
1725 std::string JSON_API valueToQuotedString(
const char *value);
1733 #endif // JSON_WRITER_H_INCLUDED 1739 #endif // ifndef JSON_AMALGATED_H_INCLUDED Outputs a Value in JSON format without formatting (not human friendly).
Definition: json.h:1589
Experimental: do not use. Allocator to customize Value internal array. Below is an example of a simpl...
Definition: json.h:1140
Writes a Value in JSON format in a human friendly way.
Definition: json.h:1624
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition: json.h:443
base class for Value iterators.
Definition: json.h:1170
array value (ordered list)
Definition: json.h:332
unsigned integer value
Definition: json.h:328
object value (collection of name/value pairs).
Definition: json.h:333
std::istream & operator>>(std::istream &, Value &)
Read from 'sin' into 'root'.
Definition: jsoncpp.cpp:943
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition: json.h:436
Lightweight wrapper to tag static string.
Definition: json.h:363
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition: json.h:438
const iterator for object and array value.
Definition: json.h:1228
Experimental and untested: represents an element of the "path" to access a node.
Definition: json.h:768
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
Definition: json.h:427
'null' value
Definition: json.h:326
bool allowComments_
true if comments are allowed. Default: true.
Definition: json.h:277
CommentPlacement
Definition: json.h:336
ValueInternalMap hash-map bucket chain link (for internal use only).
Definition: json.h:891
Allocator to customize Value internal map. Below is an example of a simple implementation (default im...
Definition: json.h:875
JSON (JavaScript Object Notation).
Definition: json.h:152
Experimental and untested: represents a "path" to access a node.
Definition: json.h:801
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition: json.h:445
double value
Definition: json.h:329
A simplified deque implementation used internally by Value.
Definition: json.h:1017
Abstract class for writers.
Definition: json.h:1575
Represents a JSON value.
Definition: json.h:404
static const Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
Definition: json.h:441
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition: json.h:434
a comment on the line after a value (only make sense for root value)
Definition: json.h:340
Unserialize a JSON document into a Value.
Definition: json.h:1374
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
Definition: json.h:1680
Iterator for object and array value.
Definition: json.h:1284
A linked page based hash-table implementation used internally by Value.
Definition: json.h:926
ValueType
Type of the value held by a Value object.
Definition: json.h:324
bool strictRoot_
true if root must be either an array or an object value. Default: false.
Definition: json.h:280
bool value
Definition: json.h:331
signed integer value
Definition: json.h:327
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition: json.h:255
a comment placed on the line before a value
Definition: json.h:338
UTF-8 string value.
Definition: json.h:330
a comment just after a value on the same line
Definition: json.h:339
std::ostream & operator<<(std::ostream &, const Value &root)
Output using the StyledStreamWriter.
Definition: jsoncpp.cpp:3774
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition: json.h:429
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition: json.h:431