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) 15 # ifndef JSON_USE_CPPTL_SMALLMAP 18 # include <cpptl/smallmap.h> 20 # ifdef JSON_USE_CPPTL 21 # include <cpptl/forwards.h> 77 operator const char *()
const 121 # ifdef JSON_VALUE_USE_INTERNAL_MAP 122 friend class ValueInternalLink;
123 friend class ValueInternalMap;
131 # if defined(JSON_HAS_INT64) 134 #endif // defined(JSON_HAS_INT64) 154 # if defined(JSON_HAS_INT64) 155 static const Int64 minInt64;
158 static const Int64 maxInt64;
160 static const UInt64 maxUInt64;
161 #endif // defined(JSON_HAS_INT64) 164 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 165 # ifndef JSON_VALUE_USE_INTERNAL_MAP 169 enum DuplicationPolicy
175 CZString( ArrayIndex
index );
176 CZString(
const char *cstr, DuplicationPolicy
allocate );
177 CZString(
const CZString &other );
179 CZString &operator =(
const CZString &other );
180 bool operator<(
const CZString &other )
const;
181 bool operator==(
const CZString &other )
const;
182 ArrayIndex
index()
const;
183 const char *c_str()
const;
184 bool isStaticString()
const;
186 void swap( CZString &other );
192 # ifndef JSON_USE_CPPTL_SMALLMAP 195 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
196 # endif // ifndef JSON_USE_CPPTL_SMALLMAP 197 # endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 198 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 219 #if defined(JSON_HAS_INT64) 222 #endif // if defined(JSON_HAS_INT64) 225 Value(
const char *beginValue,
const char *endValue );
238 # ifdef JSON_USE_CPPTL 261 int compare(
const Value &other )
const;
263 const char *asCString()
const;
265 # ifdef JSON_USE_CPPTL 266 CppTL::ConstString asConstString()
const;
270 #if defined(JSON_HAS_INT64) 271 Int64 asInt64()
const;
272 UInt64 asUInt64()
const;
273 #endif // if defined(JSON_HAS_INT64) 274 LargestInt asLargestInt()
const;
275 LargestUInt asLargestUInt()
const;
276 float asFloat()
const;
277 double asDouble()
const;
283 bool isInt64()
const;
285 bool isUInt64()
const;
287 bool isDouble()
const;
288 bool isNumeric()
const;
289 bool isString()
const;
291 bool isObject()
const;
293 bool isConvertibleTo(
ValueType other )
const;
296 ArrayIndex
size()
const;
315 void resize( ArrayIndex
size );
334 const Value &operator[]( ArrayIndex
index )
const;
344 const Value &defaultValue )
const;
346 bool isValidIndex( ArrayIndex index )
const;
353 Value &operator[](
const char *
key );
355 const Value &operator[](
const char *
key )
const;
372 # ifdef JSON_USE_CPPTL 373 Value &operator[](
const CppTL::ConstString &
key );
376 const Value &operator[](
const CppTL::ConstString &
key )
const;
380 const Value &defaultValue )
const;
383 const Value &defaultValue )
const;
384 # ifdef JSON_USE_CPPTL 385 Value get(
const CppTL::ConstString &
key,
387 const Value &defaultValue )
const;
389 Value removeMember(
const char* key );
400 bool isMember(
const char *key )
const;
403 # ifdef JSON_USE_CPPTL 404 bool isMember(
const CppTL::ConstString &key )
const;
413 Members getMemberNames()
const;
421 void setComment(
const char *comment,
432 const_iterator begin()
const;
433 const_iterator
end()
const;
439 Value &resolveReference(
const char *key,
442 # ifdef JSON_VALUE_USE_INTERNAL_MAP 443 inline bool isItemAvailable()
const 445 return itemIsUsed_ == 0;
448 inline void setItemUsed(
bool isUsed =
true )
450 itemIsUsed_ = isUsed ? 1 : 0;
453 inline bool isMemberNameStatic()
const 455 return memberNameIsStatic_ == 0;
458 inline void setMemberNameIsStatic(
bool isStatic )
460 memberNameIsStatic_ = isStatic ? 1 : 0;
462 # endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 470 void setComment(
const char *
text );
491 # ifdef JSON_VALUE_USE_INTERNAL_MAP 492 ValueInternalArray *array_;
493 ValueInternalMap *
map_;
501 unsigned int allocated_ : 1;
502 # ifdef JSON_VALUE_USE_INTERNAL_MAP 503 unsigned int itemIsUsed_ : 1;
504 unsigned int memberNameIsStatic_ : 1;
506 CommentInfo *comments_;
557 const Value &defaultValue )
const;
562 typedef std::vector<const PathArgument *> InArgs;
563 typedef std::vector<PathArgument> Args;
569 InArgs::const_iterator &itInArg,
570 PathArgument::Kind
kind );
579 #ifdef JSON_VALUE_USE_INTERNAL_MAP 627 virtual ~ValueMapAllocator();
628 virtual ValueInternalMap *newMap() = 0;
629 virtual ValueInternalMap *newMapCopy(
const ValueInternalMap &other ) = 0;
630 virtual void destructMap( ValueInternalMap *
map ) = 0;
631 virtual ValueInternalLink *allocateMapBuckets(
unsigned int size ) = 0;
632 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
633 virtual ValueInternalLink *allocateMapLink() = 0;
634 virtual void releaseMapLink( ValueInternalLink *
link ) = 0;
643 enum { itemPerLink = 6 };
651 ~ValueInternalLink();
653 Value items_[itemPerLink];
654 char *keys_[itemPerLink];
655 ValueInternalLink *previous_;
656 ValueInternalLink *next_;
677 typedef unsigned int HashKey;
678 typedef unsigned int BucketIndex;
680 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 690 ValueInternalMap *
map_;
691 ValueInternalLink *link_;
692 BucketIndex itemIndex_;
693 BucketIndex bucketIndex_;
695 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 698 ValueInternalMap(
const ValueInternalMap &other );
699 ValueInternalMap &operator =(
const ValueInternalMap &other );
702 void swap( ValueInternalMap &other );
704 BucketIndex
size()
const;
708 bool reserveDelta( BucketIndex growth );
710 bool reserve( BucketIndex newItemCount );
716 Value &resolveReference(
const char *key,
719 void remove(
const char *
key );
721 void doActualRemove( ValueInternalLink *
link,
723 BucketIndex bucketIndex );
725 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
727 Value &setNewItem(
const char *key,
729 ValueInternalLink *link,
732 Value &unsafeAdd(
const char *key,
736 HashKey
hash(
const char *key )
const;
738 int compare(
const ValueInternalMap &other )
const;
741 void makeBeginIterator( IteratorState &it )
const;
742 void makeEndIterator( IteratorState &it )
const;
743 static bool equals(
const IteratorState &
x,
const IteratorState &other );
744 static void increment( IteratorState &iterator );
745 static void incrementBucket( IteratorState &iterator );
746 static void decrement( IteratorState &iterator );
747 static const char *
key(
const IteratorState &iterator );
748 static const char *
key(
const IteratorState &iterator,
bool &isStatic );
749 static Value &
value(
const IteratorState &iterator );
750 static int distance(
const IteratorState &x,
const IteratorState &
y );
753 ValueInternalLink *buckets_;
754 ValueInternalLink *tailLink_;
755 BucketIndex bucketsSize_;
756 BucketIndex itemCount_;
775 enum { itemsPerPage = 8 };
777 typedef unsigned int PageIndex;
779 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 784 , currentPageIndex_(0)
785 , currentItemIndex_(0)
788 ValueInternalArray *array_;
789 Value **currentPageIndex_;
790 unsigned int currentItemIndex_;
792 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 794 ValueInternalArray();
795 ValueInternalArray(
const ValueInternalArray &other );
796 ValueInternalArray &operator =(
const ValueInternalArray &other );
797 ~ValueInternalArray();
798 void swap( ValueInternalArray &other );
801 void resize( ArrayIndex newSize );
807 ArrayIndex
size()
const;
809 int compare(
const ValueInternalArray &other )
const;
812 static bool equals(
const IteratorState &
x,
const IteratorState &other );
813 static void increment( IteratorState &iterator );
814 static void decrement( IteratorState &iterator );
815 static Value &dereference(
const IteratorState &iterator );
816 static Value &unsafeDereference(
const IteratorState &iterator );
817 static int distance(
const IteratorState &x,
const IteratorState &
y );
818 static ArrayIndex indexOf(
const IteratorState &iterator );
819 void makeBeginIterator( IteratorState &it )
const;
820 void makeEndIterator( IteratorState &it )
const;
821 void makeIterator( IteratorState &it, ArrayIndex index )
const;
823 void makeIndexValid( ArrayIndex index );
827 PageIndex pageCount_;
892 virtual ~ValueArrayAllocator();
893 virtual ValueInternalArray *newArray() = 0;
894 virtual ValueInternalArray *newArrayCopy(
const ValueInternalArray &other ) = 0;
895 virtual void destructArray( ValueInternalArray *
array ) = 0;
907 virtual void reallocateArrayPageIndex(
Value **&indexes,
908 ValueInternalArray::PageIndex &indexCount,
909 ValueInternalArray::PageIndex minNewIndexCount ) = 0;
910 virtual void releaseArrayPageIndex(
Value **indexes,
911 ValueInternalArray::PageIndex indexCount ) = 0;
912 virtual Value *allocateArrayPage() = 0;
913 virtual void releaseArrayPage(
Value *
value ) = 0;
915 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 929 #ifndef JSON_VALUE_USE_INTERNAL_MAP 938 return isEqual( other );
943 return !isEqual( other );
946 difference_type operator -(
const SelfType &other )
const 948 return computeDistance( other );
958 const char *memberName()
const;
961 Value &deref()
const;
967 difference_type computeDistance(
const SelfType &other )
const;
969 bool isEqual(
const SelfType &other )
const;
971 void copy(
const SelfType &other );
974 #ifndef JSON_VALUE_USE_INTERNAL_MAP 975 Value::ObjectValues::iterator current_;
981 ValueInternalArray::IteratorState array_;
982 ValueInternalMap::IteratorState
map_;
1005 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1016 SelfType
temp( *
this );
1023 SelfType
temp( *
this );
1065 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1066 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t );
1073 SelfType &
operator =(
const SelfType &other );
1077 SelfType
temp( *
this );
1084 SelfType
temp( *
this );
1111 #endif // CPPTL_JSON_H_INCLUDED UTF-8 string value.
Definition: value.h:36
bool isIntegral(float value)
Definition: MathExtras.h:417
Int64 LargestInt
Definition: config.h:91
'null' value
Definition: value.h:32
constexpr bool operator>(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:60
unsigned int ArrayIndex
Definition: forwards.h:23
#define size
Definition: float-mm.c:27
static const Value & null
We regret this reference to a global instance; prefer the simpler Value().
Definition: value.h:139
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
a comment just after a value on the same line
Definition: value.h:45
std::vector< std::string > Members
Definition: value.h:126
def copy(src_path, out_dir, rel_path)
Definition: blink-import.py:86
required HashAlgorithmIdentifier hash
Definition: WebCryptoAPI.idl:276
base class for Value iterators.
Definition: value.h:921
int difference_type
Definition: value.h:925
Definition: XMLHttpRequest.idl:39
def root
Definition: pyjsontestrunner.py:60
GLuint GLuint end
Definition: gl2ext.h:323
std::integral_constant< bool, B > bool_
Definition: Brigand.h:836
GenericValue * ValueIterator
Value iterator for iterating in array.
Definition: document.h:431
std::string kind
Definition: peerconnection_jni.cc:2054
Json::ArrayIndex ArrayIndex
Definition: value.h:137
array value (ordered list)
Definition: value.h:38
typename detail::make_map< Ts... >::type map
Definition: Brigand.h:223
TimeDelta operator*(T a, TimeDelta td)
Definition: timedelta.h:123
clear
Definition: complexityMeasures.m:1
path
Definition: generate.py:74
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition: value.h:150
Lightweight wrapper to tag static string.
Definition: value.h:69
CFArrayRef array
Definition: AVFoundationCFSoftLinking.h:129
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition: value.h:152
Json::LargestUInt LargestUInt
Definition: value.h:136
int difference_type
Definition: value.h:996
const iterator for object and array value.
Definition: value.h:991
detail::append_impl< Ts... > append
Definition: Brigand.h:133
unsigned int size_t
Definition: value.h:1053
object value (collection of name/value pairs).
Definition: value.h:39
bool operator!=(const Handle< T > &a, const Handle< U > &b)
Definition: Handle.h:159
Object allocate(size_t size)
Definition: stress.cpp:105
bool operator!(const String &str)
Definition: WTFString.h:517
Experimental and untested: represents an element of the "path" to access a node.
Definition: value.h:512
GLint location
Definition: gl2.h:455
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
Definition: value.h:141
SelfType & operator--()
Definition: value.h:1028
CommentPlacement
Definition: value.h:42
SelfType & operator--()
Definition: value.h:1089
StaticString(const char *czstring)
Definition: value.h:72
ValueConstIterator SelfType
Definition: value.h:999
UInt64 LargestUInt
Definition: config.h:92
constexpr bool operator>=(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:62
bool value
Definition: value.h:37
EGLSurface EGLint x
Definition: eglext.h:950
int difference_type
Definition: value.h:1054
ValueConstIterator const_iterator
Definition: value.h:128
GLuint index
Definition: gl2.h:383
EGLAttrib * value
Definition: eglext.h:120
a comment placed on the line before a value
Definition: value.h:44
JSON (JavaScript Object Notation).
Definition: value.h:26
ValueIteratorBase SelfType
Definition: value.h:926
JSString * asString(JSValue)
Definition: JSString.h:491
ValueIterator SelfType
Definition: value.h:1057
Experimental and untested: represents a "path" to access a node.
Definition: value.h:545
unsigned integer value
Definition: value.h:34
double value
Definition: value.h:35
SelfType operator--(int)
Definition: value.h:1021
Json::LargestInt LargestInt
Definition: value.h:135
EGLSurface EGLint EGLint y
Definition: eglext.h:950
const char * c_str() const
Definition: value.h:82
SelfType operator--(int)
Definition: value.h:1082
Json::UInt UInt
Definition: value.h:129
SelfType & operator++()
Definition: value.h:1095
unsigned long long int UInt64
Definition: config.h:89
bool operator==(const Handle< T > &a, const Handle< U > &b)
Definition: Handle.h:144
EGLenum type
Definition: eglext.h:63
Json::Int Int
Definition: value.h:130
GLsizei const GLchar *const * string
Definition: gl2.h:479
long long int Int64
Definition: config.h:88
Value * pointer
Definition: value.h:1056
Represents a JSON value.
Definition: value.h:118
signed integer value
Definition: value.h:33
ValueIterator iterator
Definition: value.h:127
const Value * pointer
Definition: value.h:998
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition: value.h:148
const Value & reference
Definition: value.h:997
constexpr bool operator<=(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:61
unsigned int UInt
Definition: config.h:77
GLsizei GLsizei GLfloat distance
Definition: gl2ext.h:2866
root value)
Definition: value.h:47
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:595
Iterator for object and array value.
Definition: value.h:1049
SelfType & operator++()
Definition: value.h:1034
SelfType operator++(int)
Definition: value.h:1014
ValueType
Type of the value held by a Value object.
Definition: value.h:30
constexpr bool operator<(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:59
a comment on the line after a value (only make sense for root value)
Definition: value.h:46
std::map< CZString, Value > ObjectValues
Definition: value.h:193
void swap(JSRetainPtr< T > &a, JSRetainPtr< T > &b)
Definition: JSRetainPtr.h:179
#define JSON_API
Definition: config.h:53
SelfType operator++(int)
Definition: value.h:1075
CFArrayRef CFTypeRef key
Definition: AVFoundationCFSoftLinking.h:129
unsigned int size_t
Definition: value.h:924
int Int
Definition: config.h:76
bool isInt(TypedArrayType type)
Definition: TypedArrayType.h:149
bool isArray(ExecState *exec, JSValue argumentValue)
Definition: ArrayConstructor.h:71
unsigned int size_t
Definition: value.h:995
temp
Definition: parse_delay_file.m:64
string state
Definition: buildtests.py:34
Value & reference
Definition: value.h:1055
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition: value.h:143
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition: value.h:145