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 {
232 CZString(ArrayIndex index);
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;
247 ArrayIndex index()
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;
373 UInt64 asUInt64()
const;
374 #endif // if defined(JSON_HAS_INT64)
375 LargestInt asLargestInt()
const;
376 LargestUInt asLargestUInt()
const;
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;
397 ArrayIndex size()
const;
404 explicit operator bool()
const;
416 void resize(ArrayIndex size);
424 Value& operator[](ArrayIndex index);
432 Value& operator[](
int index);
437 const Value& operator[](ArrayIndex index)
const;
442 const Value& operator[](
int index)
const;
447 Value get(ArrayIndex index,
const Value& defaultValue)
const;
449 bool isValidIndex(ArrayIndex 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);
547 bool removeIndex(ArrayIndex i,
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);
716 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
718 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
720 difference_type
operator-(
const SelfType& other)
const {
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_;
768 explicit ValueIteratorBase(const
Value::ObjectValues::iterator& current);
793 SelfType& operator=(
const ValueIteratorBase& other);
796 SelfType temp(*
this);
802 SelfType temp(*
this);
842 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
844 SelfType& operator=(
const SelfType& other);
847 SelfType temp(*
this);
853 SelfType temp(*
this);
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)
pointer operator->() 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.
reference operator*() const
base class for Value iterators.
array value (ordered list)
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.
Lightweight wrapper to tag static string.
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Json::LargestUInt LargestUInt
difference_type computeDistance(const SelfType &other) const
bool operator!=(const SelfType &other) 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
const char * c_str() const
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
static const Value & nullRef
just a kludge for binary-compatibility; same as null
std::bidirectional_iterator_tag iterator_category
difference_type operator-(const SelfType &other) const
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
reference operator*() const
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.
std::vector< std::string > Members
static const Value & null
We regret this reference to a global instance; prefer the simpler Value().
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.
bool operator==(const SelfType &other) const
pointer operator->() const
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.