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)
195 static Value const& nullSingleton();
211 #if defined(JSON_HAS_INT64)
212 static const Int64 minInt64;
218 #endif // defined(JSON_HAS_INT64)
221 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
224 enum DuplicationPolicy {
230 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
231 CZString(CZString
const& other);
232 #if JSON_HAS_RVALUE_REFERENCES
233 CZString(CZString&& other);
236 CZString& operator=(CZString other);
237 bool operator<(CZString
const& other)
const;
241 char const* data()
const;
242 unsigned length()
const;
243 bool isStaticString()
const;
246 void swap(CZString& other);
248 struct StringStorage {
250 unsigned length_: 30;
256 StringStorage storage_;
261 #ifndef JSON_USE_CPPTL_SMALLMAP
262 typedef std::map<CZString, Value> ObjectValues;
264 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
265 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
266 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
287 #if defined(JSON_HAS_INT64)
290 #endif // if defined(JSON_HAS_INT64)
292 Value(
const char* value);
293 Value(
const char* begin,
const char* end);
311 #ifdef JSON_USE_CPPTL
312 Value(
const CppTL::ConstString& value);
317 #if JSON_HAS_RVALUE_REFERENCES
327 void swap(
Value& other);
329 void swapPayload(
Value& other);
334 bool operator<(
const Value& other)
const;
335 bool operator<=(
const Value& other)
const;
336 bool operator>=(
const Value& other)
const;
337 bool operator>(
const Value& other)
const;
340 int compare(
const Value& other)
const;
342 const char* asCString()
const;
343 #if JSONCPP_USING_SECURE_MEMORY
344 unsigned getCStringLength()
const;
351 char const** begin,
char const** end)
const;
352 #ifdef JSON_USE_CPPTL
353 CppTL::ConstString asConstString()
const;
357 #if defined(JSON_HAS_INT64)
358 Int64 asInt64()
const;
360 #endif // if defined(JSON_HAS_INT64)
363 float asFloat()
const;
364 double asDouble()
const;
370 bool isInt64()
const;
372 bool isUInt64()
const;
373 bool isIntegral()
const;
374 bool isDouble()
const;
375 bool isNumeric()
const;
376 bool isString()
const;
377 bool isArray()
const;
378 bool isObject()
const;
380 bool isConvertibleTo(
ValueType other)
const;
390 bool operator!()
const;
418 Value& operator[](
int index);
428 const Value& operator[](
int index)
const;
444 Value& operator[](
const char* key);
447 const Value& operator[](
const char* key)
const;
468 #ifdef JSON_USE_CPPTL
469 Value& operator[](
const CppTL::ConstString& key);
473 const Value& operator[](
const CppTL::ConstString& key)
const;
475 Value get(
const char* key,
const Value& defaultValue)
const;
481 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
486 #ifdef JSON_USE_CPPTL
487 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
491 Value const* find(
char const* begin,
char const* end)
const;
498 Value const* demand(
char const* begin,
char const* end);
506 Value removeMember(
const char* key);
513 bool removeMember(
const char* key,
Value* removed);
522 bool removeMember(
const char* begin,
const char* end,
Value* removed);
533 bool isMember(
const char* key)
const;
538 bool isMember(
const char* begin,
const char* end)
const;
539 #ifdef JSON_USE_CPPTL
540 bool isMember(
const CppTL::ConstString& key)
const;
549 Members getMemberNames()
const;
560 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
569 const_iterator begin() const;
570 const_iterator end() const;
577 void setOffsetStart(ptrdiff_t start);
578 void setOffsetLimit(ptrdiff_t limit);
579 ptrdiff_t getOffsetStart() const;
580 ptrdiff_t getOffsetLimit() const;
583 void initBasic(
ValueType type,
bool allocated = false);
585 Value& resolveReference(const
char* key);
586 Value& resolveReference(const
char* key, const
char* end);
592 void setComment(
const char* text,
size_t len);
615 unsigned int allocated_ : 1;
617 CommentInfo* comments_;
668 const Value& resolve(
const Value& root)
const;
675 typedef std::vector<const PathArgument*> InArgs;
676 typedef std::vector<PathArgument> Args;
681 InArgs::const_iterator& itInArg,
682 PathArgument::Kind kind);
722 char const* memberName() const;
726 char const* memberName(
char const** end) const;
729 Value& deref() const;
735 difference_type computeDistance(const SelfType& other) const;
737 bool isEqual(const SelfType& other) const;
739 void copy(const SelfType& other);
742 Value::ObjectValues::iterator current_;
750 explicit ValueIteratorBase(const
Value::ObjectValues::iterator& current);
775 SelfType& operator=(
const ValueIteratorBase& other);
778 SelfType temp(*
this);
784 SelfType temp(*
this);
824 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
866 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
868 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
870 #endif // CPPTL_JSON_H_INCLUDED
#define JSONCPP_DEPRECATED(message)
pointer operator->() const
#define JSON_API
If defined, indicates that the source file is amalgated 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
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.