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 const LargestInt minLargestInt;
207 #if defined(JSON_HAS_INT64) 208 static const Int64 minInt64;
214 #endif // defined(JSON_HAS_INT64) 217 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 220 enum DuplicationPolicy {
225 CZString(ArrayIndex index);
226 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
227 CZString(CZString
const& other);
228 #if JSON_HAS_RVALUE_REFERENCES 229 CZString(CZString&& other);
232 CZString& operator=(CZString other);
233 bool operator<(CZString
const& other)
const;
235 ArrayIndex index()
const;
237 char const* data()
const;
238 unsigned length()
const;
239 bool isStaticString()
const;
242 void swap(CZString& other);
244 struct StringStorage {
246 unsigned length_: 30;
252 StringStorage storage_;
257 #ifndef JSON_USE_CPPTL_SMALLMAP 258 typedef std::map<CZString, Value> ObjectValues;
260 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
261 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 262 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 283 #if defined(JSON_HAS_INT64) 286 #endif // if defined(JSON_HAS_INT64) 288 Value(
const char* value);
289 Value(
const char* begin,
const char* end);
307 #ifdef JSON_USE_CPPTL 308 Value(
const CppTL::ConstString& value);
313 #if JSON_HAS_RVALUE_REFERENCES 323 void swap(
Value& other);
325 void swapPayload(
Value& other);
330 bool operator<(
const Value& other)
const;
331 bool operator<=(
const Value& other)
const;
332 bool operator>=(
const Value& other)
const;
333 bool operator>(
const Value& other)
const;
336 int compare(
const Value& other)
const;
338 const char* asCString()
const;
339 #if JSONCPP_USING_SECURE_MEMORY 340 unsigned getCStringLength()
const;
347 char const** begin,
char const** end)
const;
348 #ifdef JSON_USE_CPPTL 349 CppTL::ConstString asConstString()
const;
353 #if defined(JSON_HAS_INT64) 354 Int64 asInt64()
const;
355 UInt64 asUInt64()
const;
356 #endif // if defined(JSON_HAS_INT64) 357 LargestInt asLargestInt()
const;
358 LargestUInt asLargestUInt()
const;
359 float asFloat()
const;
360 double asDouble()
const;
366 bool isInt64()
const;
368 bool isUInt64()
const;
369 bool isIntegral()
const;
370 bool isDouble()
const;
371 bool isNumeric()
const;
372 bool isString()
const;
373 bool isArray()
const;
374 bool isObject()
const;
376 bool isConvertibleTo(
ValueType other)
const;
379 ArrayIndex size()
const;
386 bool operator!()
const;
398 void resize(ArrayIndex size);
406 Value& operator[](ArrayIndex index);
414 Value& operator[](
int index);
419 const Value& operator[](ArrayIndex index)
const;
424 const Value& operator[](
int index)
const;
429 Value get(ArrayIndex index,
const Value& defaultValue)
const;
431 bool isValidIndex(ArrayIndex index)
const;
440 Value& operator[](
const char* key);
443 const Value& operator[](
const char* key)
const;
464 #ifdef JSON_USE_CPPTL 465 Value& operator[](
const CppTL::ConstString& key);
469 const Value& operator[](
const CppTL::ConstString& key)
const;
471 Value get(
const char* key,
const Value& defaultValue)
const;
477 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
482 #ifdef JSON_USE_CPPTL 483 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
487 Value const* find(
char const* begin,
char const* end)
const;
494 Value const* demand(
char const* begin,
char const* end);
502 Value removeMember(
const char* key);
509 bool removeMember(
const char* key,
Value* removed);
518 bool removeMember(
const char* begin,
const char* end,
Value* removed);
525 bool removeIndex(ArrayIndex i,
Value* removed);
529 bool isMember(
const char* key)
const;
534 bool isMember(
const char* begin,
const char* end)
const;
535 #ifdef JSON_USE_CPPTL 536 bool isMember(
const CppTL::ConstString& key)
const;
545 Members getMemberNames()
const;
556 void setComment(
const char* comment,
size_t len,
CommentPlacement placement);
565 const_iterator begin()
const;
566 const_iterator end()
const;
573 void setOffsetStart(ptrdiff_t start);
574 void setOffsetLimit(ptrdiff_t limit);
575 ptrdiff_t getOffsetStart()
const;
576 ptrdiff_t getOffsetLimit()
const;
579 void initBasic(
ValueType type,
bool allocated =
false);
581 Value& resolveReference(
const char* key);
582 Value& resolveReference(
const char* key,
const char* end);
588 void setComment(
const char* text,
size_t len);
611 unsigned int allocated_ : 1;
613 CommentInfo* comments_;
664 const Value& resolve(
const Value& root)
const;
671 typedef std::vector<const PathArgument*> InArgs;
672 typedef std::vector<PathArgument> Args;
677 InArgs::const_iterator& itInArg,
678 PathArgument::Kind kind);
694 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
696 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
698 difference_type
operator-(
const SelfType& other)
const {
718 char const* memberName()
const;
722 char const* memberName(
char const** end)
const;
725 Value& deref()
const;
731 difference_type computeDistance(
const SelfType& other)
const;
733 bool isEqual(
const SelfType& other)
const;
735 void copy(
const SelfType& other);
738 Value::ObjectValues::iterator current_;
774 SelfType temp(*
this);
780 SelfType temp(*
this);
820 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
822 SelfType& operator=(
const SelfType& other);
825 SelfType temp(*
this);
831 SelfType temp(*
this);
861 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 863 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 865 #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.
static const Value & null
We regret this reference to a global instance; prefer the simpler 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.
StaticString(const char *czstring)
ValueConstIterator SelfType
static const Value & nullRef
just a kludge for binary-compatibility; same as null
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.
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
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.
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.