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) 133 operator const char*()
const {
return c_str_; }
135 const char*
c_str()
const {
return c_str_; }
183 #if defined(JSON_HAS_INT64) 186 #endif // defined(JSON_HAS_INT64) 193 static Value const& nullSingleton();
209 #if defined(JSON_HAS_INT64) 210 static const Int64 minInt64;
216 #endif // defined(JSON_HAS_INT64) 219 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 222 enum DuplicationPolicy {
227 CZString(ArrayIndex index);
228 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
229 CZString(CZString
const& other);
230 #if JSON_HAS_RVALUE_REFERENCES 231 CZString(CZString&& other);
234 CZString& operator=(CZString other);
235 bool operator<(CZString
const& other)
const;
237 ArrayIndex index()
const;
239 char const* data()
const;
240 unsigned length()
const;
241 bool isStaticString()
const;
244 void swap(CZString& other);
246 struct StringStorage {
248 unsigned length_: 30;
254 StringStorage storage_;
259 #ifndef JSON_USE_CPPTL_SMALLMAP 260 typedef std::map<CZString, Value> ObjectValues;
262 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
263 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 264 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 285 #if defined(JSON_HAS_INT64) 288 #endif // if defined(JSON_HAS_INT64) 290 Value(
const char* value);
291 Value(
const char* begin,
const char* end);
309 #ifdef JSON_USE_CPPTL 310 Value(
const CppTL::ConstString& value);
315 #if JSON_HAS_RVALUE_REFERENCES 325 void swap(
Value& other);
327 void swapPayload(
Value& other);
332 bool operator<(
const Value& other)
const;
333 bool operator<=(
const Value& other)
const;
334 bool operator>=(
const Value& other)
const;
335 bool operator>(
const Value& other)
const;
338 int compare(
const Value& other)
const;
340 const char* asCString()
const;
341 #if JSONCPP_USING_SECURE_MEMORY 342 unsigned getCStringLength()
const;
349 char const** begin,
char const** end)
const;
350 #ifdef JSON_USE_CPPTL 351 CppTL::ConstString asConstString()
const;
355 #if defined(JSON_HAS_INT64) 356 Int64 asInt64()
const;
357 UInt64 asUInt64()
const;
358 #endif // if defined(JSON_HAS_INT64) 359 LargestInt asLargestInt()
const;
360 LargestUInt asLargestUInt()
const;
361 float asFloat()
const;
362 double asDouble()
const;
368 bool isInt64()
const;
370 bool isUInt64()
const;
371 bool isIntegral()
const;
372 bool isDouble()
const;
373 bool isNumeric()
const;
374 bool isString()
const;
375 bool isArray()
const;
376 bool isObject()
const;
378 bool isConvertibleTo(
ValueType other)
const;
381 ArrayIndex size()
const;
388 bool operator!()
const;
400 void resize(ArrayIndex size);
408 Value& operator[](ArrayIndex index);
416 Value& operator[](
int index);
421 const Value& operator[](ArrayIndex index)
const;
426 const Value& operator[](
int index)
const;
431 Value get(ArrayIndex index,
const Value& defaultValue)
const;
433 bool isValidIndex(ArrayIndex index)
const;
442 Value& operator[](
const char* key);
445 const Value& operator[](
const char* key)
const;
466 #ifdef JSON_USE_CPPTL 467 Value& operator[](
const CppTL::ConstString& key);
471 const Value& operator[](
const CppTL::ConstString& key)
const;
473 Value get(
const char* key,
const Value& defaultValue)
const;
479 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
484 #ifdef JSON_USE_CPPTL 485 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
489 Value const* find(
char const* begin,
char const* end)
const;
496 Value const* demand(
char const* begin,
char const* end);
504 Value removeMember(
const char* key);
511 bool removeMember(
const char* key,
Value* removed);
520 bool removeMember(
const char* begin,
const char* end,
Value* removed);
527 bool removeIndex(ArrayIndex i,
Value* removed);
531 bool isMember(
const char* key)
const;
536 bool isMember(
const char* begin,
const char* end)
const;
537 #ifdef JSON_USE_CPPTL 538 bool isMember(
const CppTL::ConstString& key)
const;
547 Members getMemberNames()
const;
558 void setComment(
const char* comment,
size_t len,
CommentPlacement placement);
567 const_iterator begin()
const;
568 const_iterator end()
const;
575 void setOffsetStart(ptrdiff_t start);
576 void setOffsetLimit(ptrdiff_t limit);
577 ptrdiff_t getOffsetStart()
const;
578 ptrdiff_t getOffsetLimit()
const;
581 void initBasic(
ValueType type,
bool allocated =
false);
583 Value& resolveReference(
const char* key);
584 Value& resolveReference(
const char* key,
const char* end);
590 void setComment(
const char* text,
size_t len);
613 unsigned int allocated_ : 1;
615 CommentInfo* comments_;
666 const Value& resolve(
const Value& root)
const;
673 typedef std::vector<const PathArgument*> InArgs;
674 typedef std::vector<PathArgument> Args;
679 InArgs::const_iterator& itInArg,
680 PathArgument::Kind kind);
696 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
698 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
700 difference_type
operator-(
const SelfType& other)
const {
720 char const* memberName()
const;
724 char const* memberName(
char const** end)
const;
727 Value& deref()
const;
733 difference_type computeDistance(
const SelfType& other)
const;
735 bool isEqual(
const SelfType& other)
const;
737 void copy(
const SelfType& other);
740 Value::ObjectValues::iterator current_;
776 SelfType temp(*
this);
782 SelfType temp(*
this);
822 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
824 SelfType& operator=(
const SelfType& other);
827 SelfType temp(*
this);
833 SelfType temp(*
this);
863 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 865 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 867 #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 amalgated 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.