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) 16 #ifndef JSON_USE_CPPTL_SMALLMAP 19 #include <cpptl/smallmap.h> 22 #include <cpptl/forwards.h> 28 #if !defined(JSONCPP_NORETURN) 29 # if defined(_MSC_VER) 30 # define JSONCPP_NORETURN __declspec(noreturn) 31 # elif defined(__GNUC__) 32 # define JSONCPP_NORETURN __attribute__ ((__noreturn__)) 34 # define JSONCPP_NORETURN 40 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 42 #pragma warning(disable : 4251) 43 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 135 operator const char*()
const {
return c_str_; }
137 const char*
c_str()
const {
return c_str_; }
185 #if defined(JSON_HAS_INT64) 188 #endif // defined(JSON_HAS_INT64) 198 static Value const& nullSingleton();
214 #if defined(JSON_HAS_INT64) 215 static const Int64 minInt64;
221 #endif // defined(JSON_HAS_INT64) 224 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 227 enum DuplicationPolicy {
233 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
234 CZString(CZString
const& other);
235 #if JSON_HAS_RVALUE_REFERENCES 236 CZString(CZString&& other);
239 CZString& operator=(
const CZString& other);
241 #if JSON_HAS_RVALUE_REFERENCES 242 CZString& operator=(CZString&& other);
245 bool operator<(CZString
const& other)
const;
249 char const* data()
const;
250 unsigned length()
const;
251 bool isStaticString()
const;
254 void swap(CZString& other);
256 struct StringStorage {
258 unsigned length_: 30;
264 StringStorage storage_;
269 #ifndef JSON_USE_CPPTL_SMALLMAP 270 typedef std::map<CZString, Value> ObjectValues;
272 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
273 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 274 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 295 #if defined(JSON_HAS_INT64) 298 #endif // if defined(JSON_HAS_INT64) 300 Value(
const char* value);
301 Value(
const char* begin,
const char* end);
319 #ifdef JSON_USE_CPPTL 320 Value(
const CppTL::ConstString& value);
325 #if JSON_HAS_RVALUE_REFERENCES 336 void swap(
Value& other);
338 void swapPayload(
Value& other);
341 void copy(
const Value& other);
343 void copyPayload(
const Value& other);
348 bool operator<(
const Value& other)
const;
349 bool operator<=(
const Value& other)
const;
350 bool operator>=(
const Value& other)
const;
351 bool operator>(
const Value& other)
const;
354 int compare(
const Value& other)
const;
356 const char* asCString()
const;
357 #if JSONCPP_USING_SECURE_MEMORY 358 unsigned getCStringLength()
const;
365 char const** begin,
char const** end)
const;
366 #ifdef JSON_USE_CPPTL 367 CppTL::ConstString asConstString()
const;
371 #if defined(JSON_HAS_INT64) 372 Int64 asInt64()
const;
374 #endif // if defined(JSON_HAS_INT64) 377 float asFloat()
const;
378 double asDouble()
const;
384 bool isInt64()
const;
386 bool isUInt64()
const;
387 bool isIntegral()
const;
388 bool isDouble()
const;
389 bool isNumeric()
const;
390 bool isString()
const;
391 bool isArray()
const;
392 bool isObject()
const;
394 bool isConvertibleTo(
ValueType other)
const;
404 explicit operator bool()
const;
432 Value& operator[](
int index);
442 const Value& operator[](
int index)
const;
455 #if JSON_HAS_RVALUE_REFERENCES 462 Value& operator[](
const char* key);
465 const Value& operator[](
const char* key)
const;
486 #ifdef JSON_USE_CPPTL 487 Value& operator[](
const CppTL::ConstString& key);
491 const Value& operator[](
const CppTL::ConstString& key)
const;
493 Value get(
const char* key,
const Value& defaultValue)
const;
499 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
504 #ifdef JSON_USE_CPPTL 505 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
509 Value const* find(
char const* begin,
char const* end)
const;
516 Value const* demand(
char const* begin,
char const* end);
524 void removeMember(
const char* key);
531 bool removeMember(
const char* key,
Value* removed);
540 bool removeMember(
const char* begin,
const char* end,
Value* removed);
551 bool isMember(
const char* key)
const;
556 bool isMember(
const char* begin,
const char* end)
const;
557 #ifdef JSON_USE_CPPTL 558 bool isMember(
const CppTL::ConstString& key)
const;
567 Members getMemberNames()
const;
578 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
587 const_iterator begin() const;
588 const_iterator end() const;
595 void setOffsetStart(ptrdiff_t start);
596 void setOffsetLimit(ptrdiff_t limit);
597 ptrdiff_t getOffsetStart() const;
598 ptrdiff_t getOffsetLimit() const;
601 void initBasic(
ValueType type,
bool allocated = false);
603 Value& resolveReference(const
char* key);
604 Value& resolveReference(const
char* key, const
char* end);
610 void setComment(
const char* text,
size_t len);
633 unsigned int allocated_ : 1;
635 CommentInfo* comments_;
686 const Value& resolve(
const Value& root)
const;
693 typedef std::vector<const PathArgument*> InArgs;
694 typedef std::vector<PathArgument> Args;
699 InArgs::const_iterator& itInArg,
700 PathArgument::Kind kind);
740 char const* memberName() const;
744 char const* memberName(
char const** end) const;
747 Value& deref() const;
753 difference_type computeDistance(const SelfType& other) const;
755 bool isEqual(const SelfType& other) const;
757 void copy(const SelfType& other);
760 Value::ObjectValues::iterator current_;
842 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
884 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 886 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 888 #endif // CPPTL_JSON_H_INCLUDED
#define JSONCPP_DEPRECATED(message)
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
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.
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
static const Value & nullRef
just a kludge for binary-compatibility; same as null
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
ValueConstIterator const_iterator
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
bool operator==(const SecureAllocator< T > &, const SecureAllocator< U > &)
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.
Exceptions which the user cannot easily avoid.
a comment on the line after a value (only make sense for
Iterator for object and array value.
difference_type operator-(const SelfType &other) const
std::vector< std::string > Members
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
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Base class for all exceptions we throw.
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.