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) 141 static const LargestInt minLargestInt;
143 static const LargestInt maxLargestInt;
145 static const LargestUInt maxLargestUInt;
148 static const Int minInt;
150 static const Int maxInt;
152 static const UInt maxUInt;
154 # if defined(JSON_HAS_INT64) 155 static const Int64 minInt64;
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) 220 Value( Int64
value );
221 Value( UInt64
value );
222 #endif // if defined(JSON_HAS_INT64) 223 Value(
double value );
224 Value(
const char *
value );
225 Value(
const char *beginValue,
const char *endValue );
236 Value(
const StaticString &
value );
238 # ifdef JSON_USE_CPPTL 239 Value(
const CppTL::ConstString &
value );
242 Value(
const Value &other );
245 Value &operator=(
const Value &other );
249 void swap( Value &other );
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 );
322 Value &operator[]( ArrayIndex
index );
329 Value &operator[](
int index );
334 const Value &operator[]( ArrayIndex
index )
const;
339 const Value &operator[](
int index )
const;
343 Value
get( ArrayIndex
index,
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;
371 Value &operator[](
const StaticString &
key );
372 # ifdef JSON_USE_CPPTL 373 Value &operator[](
const CppTL::ConstString &
key );
376 const Value &operator[](
const CppTL::ConstString &
key )
const;
378 Value
get(
const char *
key,
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_;
500 # ifdef JSON_VALUE_USE_INTERNAL_MAP 501 unsigned int itemIsUsed_ : 1;
502 int memberNameIsStatic_ : 1;
504 CommentInfo *comments_;
553 const Value &resolve(
const Value &
root )
const;
554 Value resolve(
const Value &
root,
555 const Value &defaultValue )
const;
557 Value &make( Value &
root )
const;
560 typedef std::vector<const PathArgument *> InArgs;
561 typedef std::vector<PathArgument> Args;
567 InArgs::const_iterator &itInArg,
568 PathArgument::Kind
kind );
577 #ifdef JSON_VALUE_USE_INTERNAL_MAP 625 virtual ~ValueMapAllocator();
626 virtual ValueInternalMap *newMap() = 0;
627 virtual ValueInternalMap *newMapCopy(
const ValueInternalMap &other ) = 0;
628 virtual void destructMap( ValueInternalMap *
map ) = 0;
629 virtual ValueInternalLink *allocateMapBuckets(
unsigned int size ) = 0;
630 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
631 virtual ValueInternalLink *allocateMapLink() = 0;
632 virtual void releaseMapLink( ValueInternalLink *
link ) = 0;
641 enum { itemPerLink = 6 };
649 ~ValueInternalLink();
651 Value items_[itemPerLink];
652 char *keys_[itemPerLink];
653 ValueInternalLink *previous_;
654 ValueInternalLink *next_;
675 typedef unsigned int HashKey;
676 typedef unsigned int BucketIndex;
678 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 688 ValueInternalMap *
map_;
689 ValueInternalLink *link_;
690 BucketIndex itemIndex_;
691 BucketIndex bucketIndex_;
693 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 696 ValueInternalMap(
const ValueInternalMap &other );
697 ValueInternalMap &operator =(
const ValueInternalMap &other );
700 void swap( ValueInternalMap &other );
702 BucketIndex
size()
const;
706 bool reserveDelta( BucketIndex growth );
708 bool reserve( BucketIndex newItemCount );
710 const Value *
find(
const char *
key )
const;
712 Value *
find(
const char *
key );
714 Value &resolveReference(
const char *
key,
717 void remove(
const char *
key );
719 void doActualRemove( ValueInternalLink *
link,
721 BucketIndex bucketIndex );
723 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
725 Value &setNewItem(
const char *
key,
727 ValueInternalLink *
link,
730 Value &unsafeAdd(
const char *
key,
734 HashKey
hash(
const char *
key )
const;
736 int compare(
const ValueInternalMap &other )
const;
739 void makeBeginIterator( IteratorState &it )
const;
740 void makeEndIterator( IteratorState &it )
const;
741 static bool equals(
const IteratorState &
x,
const IteratorState &other );
742 static void increment( IteratorState &
iterator );
743 static void incrementBucket( IteratorState &
iterator );
744 static void decrement( IteratorState &
iterator );
745 static const char *
key(
const IteratorState &
iterator );
746 static const char *
key(
const IteratorState &
iterator,
bool &isStatic );
748 static int distance(
const IteratorState &
x,
const IteratorState &
y );
751 ValueInternalLink *buckets_;
752 ValueInternalLink *tailLink_;
753 BucketIndex bucketsSize_;
754 BucketIndex itemCount_;
773 enum { itemsPerPage = 8 };
775 typedef unsigned int PageIndex;
777 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 782 , currentPageIndex_(0)
783 , currentItemIndex_(0)
786 ValueInternalArray *array_;
787 Value **currentPageIndex_;
788 unsigned int currentItemIndex_;
790 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 792 ValueInternalArray();
793 ValueInternalArray(
const ValueInternalArray &other );
794 ValueInternalArray &operator =(
const ValueInternalArray &other );
795 ~ValueInternalArray();
796 void swap( ValueInternalArray &other );
799 void resize( ArrayIndex newSize );
801 Value &resolveReference( ArrayIndex
index );
805 ArrayIndex
size()
const;
807 int compare(
const ValueInternalArray &other )
const;
810 static bool equals(
const IteratorState &
x,
const IteratorState &other );
811 static void increment( IteratorState &
iterator );
812 static void decrement( IteratorState &
iterator );
813 static Value &dereference(
const IteratorState &
iterator );
814 static Value &unsafeDereference(
const IteratorState &
iterator );
815 static int distance(
const IteratorState &
x,
const IteratorState &
y );
816 static ArrayIndex indexOf(
const IteratorState &
iterator );
817 void makeBeginIterator( IteratorState &it )
const;
818 void makeEndIterator( IteratorState &it )
const;
819 void makeIterator( IteratorState &it, ArrayIndex
index )
const;
821 void makeIndexValid( ArrayIndex
index );
825 PageIndex pageCount_;
890 virtual ~ValueArrayAllocator();
891 virtual ValueInternalArray *newArray() = 0;
892 virtual ValueInternalArray *newArrayCopy(
const ValueInternalArray &other ) = 0;
893 virtual void destructArray( ValueInternalArray *
array ) = 0;
905 virtual void reallocateArrayPageIndex( Value **&indexes,
906 ValueInternalArray::PageIndex &indexCount,
907 ValueInternalArray::PageIndex minNewIndexCount ) = 0;
908 virtual void releaseArrayPageIndex( Value **indexes,
909 ValueInternalArray::PageIndex indexCount ) = 0;
910 virtual Value *allocateArrayPage() = 0;
911 virtual void releaseArrayPage( Value *
value ) = 0;
913 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 927 #ifndef JSON_VALUE_USE_INTERNAL_MAP 936 return isEqual( other );
941 return !isEqual( other );
944 difference_type operator -(
const SelfType &other )
const 946 return computeDistance( other );
956 const char *memberName()
const;
959 Value &deref()
const;
965 difference_type computeDistance(
const SelfType &other )
const;
967 bool isEqual(
const SelfType &other )
const;
969 void copy(
const SelfType &other );
972 #ifndef JSON_VALUE_USE_INTERNAL_MAP 973 Value::ObjectValues::iterator current_;
979 ValueInternalArray::IteratorState array_;
980 ValueInternalMap::IteratorState
map_;
1003 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1014 SelfType
temp( *
this );
1021 SelfType
temp( *
this );
1063 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1064 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t );
1071 SelfType &
operator =(
const SelfType &other );
1075 SelfType
temp( *
this );
1082 SelfType
temp( *
this );
1109 #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
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:923
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
CFArrayRef array
Definition: AVFoundationCFSoftLinking.h:129
Json::LargestUInt LargestUInt
Definition: value.h:136
int difference_type
Definition: value.h:994
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:1051
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 UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition: value.h:160
SelfType & operator--()
Definition: value.h:1026
CommentPlacement
Definition: value.h:42
SelfType & operator--()
Definition: value.h:1087
StaticString(const char *czstring)
Definition: value.h:72
ValueConstIterator SelfType
Definition: value.h:997
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
static const Value null
Definition: value.h:139
EGLSurface EGLint x
Definition: eglext.h:950
int difference_type
Definition: value.h:1052
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:924
Json::Int64 Int64
Definition: value.h:133
JSString * asString(JSValue)
Definition: JSString.h:491
ValueIterator SelfType
Definition: value.h:1055
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:1019
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:1080
Json::UInt UInt
Definition: value.h:129
SelfType & operator++()
Definition: value.h:1093
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::UInt64 UInt64
Definition: value.h:132
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:1054
signed integer value
Definition: value.h:33
ValueIterator iterator
Definition: value.h:127
const Value * pointer
Definition: value.h:996
const Value & reference
Definition: value.h:995
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:1032
SelfType operator++(int)
Definition: value.h:1012
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
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition: value.h:158
SelfType operator++(int)
Definition: value.h:1073
CFArrayRef CFTypeRef key
Definition: AVFoundationCFSoftLinking.h:129
unsigned int size_t
Definition: value.h:922
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:993
temp
Definition: parse_delay_file.m:64
string state
Definition: buildtests.py:34
Value & reference
Definition: value.h:1053