6 #ifndef CPPTL_JSON_H_INCLUDED 7 #define CPPTL_JSON_H_INCLUDED 9 #if !defined(JSON_IS_AMALGAMATION) 11 #endif // if !defined(JSON_IS_AMALGAMATION) 18 #ifndef JSON_USE_CPPTL_SMALLMAP 21 #include <cpptl/smallmap.h> 24 #include <cpptl/forwards.h> 30 #if !defined(JSONCPP_NORETURN) 32 #define JSONCPP_NORETURN __declspec(noreturn) 33 #elif defined(__GNUC__) 34 #define JSONCPP_NORETURN __attribute__((__noreturn__)) 36 #define JSONCPP_NORETURN 42 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 44 #pragma warning(disable : 4251) 45 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 53 #if JSON_USE_EXCEPTION 147 operator const char*()
const {
return c_str_; }
149 const char*
c_str()
const {
return c_str_; }
198 #if defined(JSON_HAS_INT64) 201 #endif // defined(JSON_HAS_INT64) 210 static const Value& nullRef;
212 static Value const& nullSingleton();
229 #if defined(JSON_HAS_INT64) 230 static const Int64 minInt64;
236 #endif // defined(JSON_HAS_INT64) 249 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 252 enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
254 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
255 CZString(CZString
const& other);
256 CZString(CZString&& other);
258 CZString& operator=(
const CZString& other);
259 CZString& operator=(CZString&& other);
261 bool operator<(CZString
const& other)
const;
265 char const* data()
const;
266 unsigned length()
const;
267 bool isStaticString()
const;
270 void swap(CZString& other);
272 struct StringStorage {
273 unsigned policy_ : 2;
274 unsigned length_ : 30;
280 StringStorage storage_;
285 #ifndef JSON_USE_CPPTL_SMALLMAP 286 typedef std::map<CZString, Value> ObjectValues;
288 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
289 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 290 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 311 #if defined(JSON_HAS_INT64) 314 #endif // if defined(JSON_HAS_INT64) 316 Value(
const char* value);
317 Value(
const char* begin,
const char* end);
335 #ifdef JSON_USE_CPPTL 337 Value(
const CppTL::ConstString& value);
352 void swapPayload(
Value& other);
355 void copy(
const Value& other);
357 void copyPayload(
const Value& other);
362 bool operator<(
const Value& other)
const;
363 bool operator<=(
const Value& other)
const;
364 bool operator>=(
const Value& other)
const;
365 bool operator>(
const Value& other)
const;
368 int compare(
const Value& other)
const;
370 const char* asCString()
const;
371 #if JSONCPP_USING_SECURE_MEMORY 372 unsigned getCStringLength()
const;
379 bool getString(
char const** begin,
char const** end)
const;
380 #ifdef JSON_USE_CPPTL 381 CppTL::ConstString asConstString()
const;
385 #if defined(JSON_HAS_INT64) 386 Int64 asInt64()
const;
388 #endif // if defined(JSON_HAS_INT64) 391 float asFloat()
const;
392 double asDouble()
const;
398 bool isInt64()
const;
400 bool isUInt64()
const;
401 bool isIntegral()
const;
402 bool isDouble()
const;
403 bool isNumeric()
const;
404 bool isString()
const;
405 bool isArray()
const;
406 bool isObject()
const;
408 bool isConvertibleTo(
ValueType other)
const;
446 Value& operator[](
int index);
456 const Value& operator[](
int index)
const;
473 Value& operator[](
const char* key);
476 const Value& operator[](
const char* key)
const;
498 #ifdef JSON_USE_CPPTL 499 Value& operator[](
const CppTL::ConstString& key);
503 const Value& operator[](
const CppTL::ConstString& key)
const;
505 Value get(
const char* key,
const Value& defaultValue)
const;
512 get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
517 #ifdef JSON_USE_CPPTL 518 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
522 Value const* find(
char const* begin,
char const* end)
const;
529 Value* demand(
char const* begin,
char const* end);
535 void removeMember(
const char* key);
538 void removeMember(
const String& key);
541 bool removeMember(
const char* key,
Value* removed);
548 bool removeMember(
String const& key,
Value* removed);
550 bool removeMember(
const char* begin,
const char* end,
Value* removed);
561 bool isMember(
const char* key)
const;
564 bool isMember(
const String& key)
const;
566 bool isMember(
const char* begin,
const char* end)
const;
567 #ifdef JSON_USE_CPPTL 568 bool isMember(
const CppTL::ConstString& key)
const;
577 Members getMemberNames()
const;
587 setComment(
String(comment, strlen(comment)), placement);
591 setComment(
String(comment, len), placement);
599 String toStyledString()
const;
601 const_iterator begin()
const;
602 const_iterator end()
const;
609 void setOffsetStart(ptrdiff_t start);
610 void setOffsetLimit(ptrdiff_t limit);
611 ptrdiff_t getOffsetStart()
const;
612 ptrdiff_t getOffsetLimit()
const;
616 bits_.value_type_ =
static_cast<unsigned char>(v);
618 bool isAllocated()
const {
return bits_.allocated_; }
619 void setIsAllocated(
bool v) { bits_.allocated_ = v; }
621 void initBasic(
ValueType type,
bool allocated =
false);
622 void dupPayload(
const Value& other);
623 void releasePayload();
624 void dupMeta(
const Value& other);
626 Value& resolveReference(
const char* key);
627 Value& resolveReference(
const char* key,
const char* end);
656 Comments() =
default;
657 Comments(
const Comments& that);
658 Comments(Comments&& that);
659 Comments& operator=(
const Comments& that);
660 Comments& operator=(Comments&& that);
666 using Array = std::array<String, numberOfCommentPlacement>;
667 std::unique_ptr<Array> ptr_;
690 enum Kind { kindNone = 0, kindIndex, kindKey };
693 Kind kind_{kindNone};
716 const Value& resolve(
const Value& root)
const;
723 typedef std::vector<const PathArgument*> InArgs;
724 typedef std::vector<PathArgument> Args;
726 void makePath(
const String& path,
const InArgs& in);
727 void addPathInArg(
const String& path,
729 InArgs::const_iterator& itInArg,
730 PathArgument::Kind kind);
731 static void invalidPath(
const String& path,
int location);
772 char const* memberName() const;
776 char const* memberName(
char const** end) const;
779 Value& deref() const;
785 difference_type computeDistance(const SelfType& other) const;
787 bool isEqual(const SelfType& other) const;
789 void copy(const SelfType& other);
792 Value::ObjectValues::iterator current_;
800 explicit ValueIteratorBase(
const Value::ObjectValues::iterator& current);
875 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
913 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 915 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 917 #endif // CPPTL_JSON_H_INCLUDED #define JSONCPP_DEPRECATED(message)
std::vector< String > Members
difference_type computeDistance(const SelfType &other) const
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion...
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
bool operator!=(const SelfType &other) const
PrecisionType
Type of precision for formatting of real values.
base class for Value iterators.
array value (ordered list)
reference operator*() const
bool operator==(const SelfType &other) const
Json::ArrayIndex ArrayIndex
Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
object value (collection of name/value pairs).
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
static const Value & null
We regret this reference to a global instance; prefer the simpler Value().
Lightweight wrapper to tag static string.
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
pointer operator->() const
Json::LargestUInt LargestUInt
pointer operator->() const
const iterator for object and array value.
Experimental and untested: represents an element of the "path" to access a node.
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
StaticString(const char *czstring)
ValueConstIterator SelfType
void swap(Value &a, Value &b)
ValueConstIterator const_iterator
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
bool operator==(const SecureAllocator< T > &, const SecureAllocator< U > &)
we set max number of digits after "." in string
void swap(Value &other)
Swap everything.
Experimental and untested: represents a "path" to access a node.
Json::LargestInt LargestInt
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
const char * c_str() const
std::bidirectional_iterator_tag iterator_category
reference operator*() const
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
static const UInt defaultRealPrecision
Default precision for real value for string representation.
Exceptions which the user cannot easily avoid.
a comment on the line after a value (only make sense for
we set max number of significant digits in string
Iterator for object and array value.
#define JSONCPP_OP_EXPLICIT
difference_type operator-(const SelfType &other) const
ValueType
Type of the value held by a Value object.
bool operator!=(const SecureAllocator< T > &, const SecureAllocator< U > &)
a comment placed on the line before a value
a comment just after a value on the same line
Base class for all exceptions we throw.
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.