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 131 # if defined(JSON_HAS_INT64) 134 #endif // defined(JSON_HAS_INT64) 162 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 163 # ifndef JSON_VALUE_USE_INTERNAL_MAP 167 enum DuplicationPolicy
173 CZString( ArrayIndex index );
174 CZString(
const char *cstr, DuplicationPolicy allocate );
175 CZString(
const CZString &other );
177 CZString &operator =(
const CZString &other );
178 bool operator<(
const CZString &other )
const;
179 bool operator==(
const CZString &other )
const;
180 ArrayIndex index()
const;
181 const char *c_str()
const;
182 bool isStaticString()
const;
184 void swap( CZString &other );
190 # ifndef JSON_USE_CPPTL_SMALLMAP 191 typedef std::map<CZString, Value> ObjectValues;
193 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
194 # endif // ifndef JSON_USE_CPPTL_SMALLMAP 195 # endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 196 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 217 #if defined(JSON_HAS_INT64) 218 Value( Int64 value );
219 Value( UInt64 value );
220 #endif // if defined(JSON_HAS_INT64) 221 Value(
double value );
222 Value(
const char *value );
223 Value(
const char *beginValue,
const char *endValue );
235 Value(
const std::string &value );
236 # ifdef JSON_USE_CPPTL 237 Value(
const CppTL::ConstString &value );
247 void swap(
Value &other );
251 bool operator <(
const Value &other )
const;
252 bool operator <=(
const Value &other )
const;
253 bool operator >=(
const Value &other )
const;
254 bool operator >(
const Value &other )
const;
256 bool operator ==(
const Value &other )
const;
257 bool operator !=(
const Value &other )
const;
259 int compare(
const Value &other )
const;
261 const char *asCString()
const;
262 std::string asString()
const;
263 # ifdef JSON_USE_CPPTL 264 CppTL::ConstString asConstString()
const;
268 Int64 asInt64()
const;
269 UInt64 asUInt64()
const;
270 LargestInt asLargestInt()
const;
271 LargestUInt asLargestUInt()
const;
272 float asFloat()
const;
273 double asDouble()
const;
280 bool isIntegral()
const;
281 bool isDouble()
const;
282 bool isNumeric()
const;
283 bool isString()
const;
284 bool isArray()
const;
285 bool isObject()
const;
287 bool isConvertibleTo(
ValueType other )
const;
290 ArrayIndex size()
const;
297 bool operator!()
const;
309 void resize( ArrayIndex size );
316 Value &operator[]( ArrayIndex index );
323 Value &operator[](
int index );
328 const Value &operator[]( ArrayIndex index )
const;
333 const Value &operator[](
int index )
const;
337 Value get( ArrayIndex index,
338 const Value &defaultValue )
const;
340 bool isValidIndex( ArrayIndex index )
const;
347 Value &operator[](
const char *key );
349 const Value &operator[](
const char *key )
const;
351 Value &operator[](
const std::string &key );
353 const Value &operator[](
const std::string &key )
const;
366 # ifdef JSON_USE_CPPTL 367 Value &operator[](
const CppTL::ConstString &key );
370 const Value &operator[](
const CppTL::ConstString &key )
const;
372 Value get(
const char *key,
374 const Value &defaultValue )
const;
376 Value get(
const std::string &key,
377 const Value &defaultValue )
const;
378 # ifdef JSON_USE_CPPTL 379 Value get(
const CppTL::ConstString &key,
381 const Value &defaultValue )
const;
383 Value removeMember(
const char* key );
391 Value removeMember(
const std::string &key );
394 bool isMember(
const char *key )
const;
396 bool isMember(
const std::string &key )
const;
397 # ifdef JSON_USE_CPPTL 398 bool isMember(
const CppTL::ConstString &key )
const;
407 Members getMemberNames()
const;
415 void setComment(
const char *comment,
418 void setComment(
const std::string &comment,
424 std::string toStyledString()
const;
426 const_iterator begin()
const;
427 const_iterator end()
const;
433 Value &resolveReference(
const char *key,
436 # ifdef JSON_VALUE_USE_INTERNAL_MAP 437 inline bool isItemAvailable()
const 439 return itemIsUsed_ == 0;
442 inline void setItemUsed(
bool isUsed =
true )
444 itemIsUsed_ = isUsed ? 1 : 0;
447 inline bool isMemberNameStatic()
const 449 return memberNameIsStatic_ == 0;
452 inline void setMemberNameIsStatic(
bool isStatic )
454 memberNameIsStatic_ = isStatic ? 1 : 0;
456 # endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 464 void setComment(
const char *text );
485 # ifdef JSON_VALUE_USE_INTERNAL_MAP 494 # ifdef JSON_VALUE_USE_INTERNAL_MAP 495 unsigned int itemIsUsed_ : 1;
496 int memberNameIsStatic_ : 1;
498 CommentInfo *comments_;
540 Path(
const std::string &path,
547 const Value &resolve(
const Value &root )
const;
549 const Value &defaultValue )
const;
554 typedef std::vector<const PathArgument *> InArgs;
555 typedef std::vector<PathArgument> Args;
557 void makePath(
const std::string &path,
559 void addPathInArg(
const std::string &path,
561 InArgs::const_iterator &itInArg,
562 PathArgument::Kind kind );
563 void invalidPath(
const std::string &path,
571 #ifdef JSON_VALUE_USE_INTERNAL_MAP 635 enum { itemPerLink = 6 };
646 char *keys_[itemPerLink];
672 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 684 BucketIndex itemIndex_;
685 BucketIndex bucketIndex_;
687 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 696 BucketIndex size()
const;
700 bool reserveDelta( BucketIndex growth );
702 bool reserve( BucketIndex newItemCount );
704 const Value *find(
const char *key )
const;
706 Value *find(
const char *key );
708 Value &resolveReference(
const char *key,
711 void remove(
const char *key );
715 BucketIndex bucketIndex );
719 Value &setNewItem(
const char *key,
724 Value &unsafeAdd(
const char *key,
728 HashKey hash(
const char *key )
const;
733 void makeBeginIterator( IteratorState &it )
const;
734 void makeEndIterator( IteratorState &it )
const;
735 static bool equals(
const IteratorState &x,
const IteratorState &other );
736 static void increment( IteratorState &iterator );
737 static void incrementBucket( IteratorState &iterator );
738 static void decrement( IteratorState &iterator );
739 static const char *key(
const IteratorState &iterator );
740 static const char *key(
const IteratorState &iterator,
bool &isStatic );
741 static Value &value(
const IteratorState &iterator );
742 static int distance(
const IteratorState &x,
const IteratorState &y );
747 BucketIndex bucketsSize_;
748 BucketIndex itemCount_;
767 enum { itemsPerPage = 8 };
771 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 776 , currentPageIndex_(0)
777 , currentItemIndex_(0)
781 Value **currentPageIndex_;
782 unsigned int currentItemIndex_;
784 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 793 void resize( ArrayIndex newSize );
795 Value &resolveReference( ArrayIndex index );
797 Value *find( ArrayIndex index )
const;
799 ArrayIndex size()
const;
804 static bool equals(
const IteratorState &x,
const IteratorState &other );
805 static void increment( IteratorState &iterator );
806 static void decrement( IteratorState &iterator );
807 static Value &dereference(
const IteratorState &iterator );
808 static Value &unsafeDereference(
const IteratorState &iterator );
809 static int distance(
const IteratorState &x,
const IteratorState &y );
810 static ArrayIndex indexOf(
const IteratorState &iterator );
811 void makeBeginIterator( IteratorState &it )
const;
812 void makeEndIterator( IteratorState &it )
const;
813 void makeIterator( IteratorState &it, ArrayIndex index )
const;
815 void makeIndexValid( ArrayIndex index );
819 PageIndex pageCount_;
899 virtual void reallocateArrayPageIndex(
Value **&indexes,
902 virtual void releaseArrayPageIndex(
Value **indexes,
904 virtual Value *allocateArrayPage() = 0;
905 virtual void releaseArrayPage(
Value *value ) = 0;
907 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 921 #ifndef JSON_VALUE_USE_INTERNAL_MAP 928 bool operator ==(
const SelfType &other )
const 930 return isEqual( other );
933 bool operator !=(
const SelfType &other )
const 935 return !isEqual( other );
938 difference_type operator -(
const SelfType &other )
const 940 return computeDistance( other );
950 const char *memberName()
const;
953 Value &deref()
const;
959 difference_type computeDistance(
const SelfType &other )
const;
961 bool isEqual(
const SelfType &other )
const;
963 void copy(
const SelfType &other );
966 #ifndef JSON_VALUE_USE_INTERNAL_MAP 967 Value::ObjectValues::iterator current_;
973 ValueInternalArray::IteratorState
array_;
974 ValueInternalMap::IteratorState
map_;
997 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1008 SelfType temp( *
this );
1015 SelfType temp( *
this );
1032 reference operator *()
const 1057 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1058 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t );
1060 ValueIterator(
const ValueInternalArray::IteratorState &state );
1061 ValueIterator(
const ValueInternalMap::IteratorState &state );
1065 SelfType &operator =(
const SelfType &other );
1069 SelfType temp( *
this );
1076 SelfType temp( *
this );
1093 reference operator *()
const 1103 #endif // CPPTL_JSON_H_INCLUDED
Experimental: do not use.
#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.
std::vector< std::string > Members
base class for Value iterators.
array value (ordered list)
Json::ArrayIndex ArrayIndex
object value (collection of name/value pairs).
Value::ArrayIndex ArrayIndex
ValueInternalLink * previous_
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Lightweight wrapper to tag static string.
ValueInternalMap::IteratorState map_
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Json::LargestUInt LargestUInt
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
ValueInternalMap hash-map bucket chain link (for internal use only).
ValueConstIterator const_iterator
Allocator to customize Value internal map.
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
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
A simplified deque implementation used internally by Value.
ValueInternalLink * next_
static const Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
a comment on the line after a value (only make sense for root value)
Iterator for object and array value.
A linked page based hash-table implementation used internally by Value.
ValueType
Type of the value held by a Value object.
a comment placed on the line before a value
ValueInternalArray::IteratorState array_
a comment just after a value on the same line
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.