1 // Copyright 2007-2010 Baptiste Lepilleur
2 // Distributed under MIT license, or public domain if desired and
3 // recognized in your jurisdiction.
4 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
6 #ifndef CPPTL_JSON_H_INCLUDED
7 # define CPPTL_JSON_H_INCLUDED
9 # include "json_forwards.h"
13 # ifndef JSON_USE_CPPTL_SMALLMAP
16 # include <cpptl/smallmap.h>
18 # ifdef JSON_USE_CPPTL
19 # include <cpptl/forwards.h>
22 /** \brief JSON (JavaScript Object Notation).
26 /** \brief Type of the value held by a Value object.
30 nullValue = 0, ///< 'null' value
31 intValue, ///< signed integer value
32 uintValue, ///< unsigned integer value
33 realValue, ///< double value
34 stringValue, ///< UTF-8 string value
35 booleanValue, ///< bool value
36 arrayValue, ///< array value (ordered list)
37 objectValue ///< object value (collection of name/value pairs).
42 commentBefore = 0, ///< a comment placed on the line before a value
43 commentAfterOnSameLine, ///< a comment just after a value on the same line
44 commentAfter, ///< a comment on the line after a value (only make sense for root value)
45 numberOfCommentPlacement
48 //# ifdef JSON_USE_CPPTL
49 // typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
50 // typedef CppTL::AnyEnumerator<const Value &> EnumValues;
53 /** \brief Lightweight wrapper to tag static string.
55 * Value constructor and objectValue member assignement takes advantage of the
56 * StaticString and avoid the cost of string duplication when storing the
57 * string or the member name.
61 * Json::Value aValue( StaticString("some text") );
63 * static const StaticString code("code");
64 * object[code] = 1234;
67 class JSON_API StaticString
70 explicit StaticString( const char *czstring )
75 operator const char *() const
80 const char *c_str() const
89 /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
91 * This class is a discriminated union wrapper that can represents a:
92 * - signed integer [range: Value::minInt - Value::maxInt]
93 * - unsigned integer (range: 0 - Value::maxUInt)
98 * - an ordered list of Value
99 * - collection of name/value pairs (javascript object)
101 * The type of the held value is represented by a #ValueType and
102 * can be obtained using type().
104 * values of an #objectValue or #arrayValue can be accessed using operator[]() methods.
105 * Non const methods will automatically create the a #nullValue element
106 * if it does not exist.
107 * The sequence of an #arrayValue will be automatically resize and initialized
108 * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
110 * The get() methods can be used to obtanis default value in the case the required element
113 * It is possible to iterate over the list of a #objectValue values using
114 * the getMemberNames() method.
118 friend class ValueIteratorBase;
119 # ifdef JSON_VALUE_USE_INTERNAL_MAP
120 friend class ValueInternalLink;
121 friend class ValueInternalMap;
124 typedef std::vector<std::string> Members;
125 typedef ValueIterator iterator;
126 typedef ValueConstIterator const_iterator;
127 typedef Json::UInt UInt;
128 typedef Json::Int Int;
129 typedef Json::ArrayIndex ArrayIndex;
131 static const Value null;
132 static const Int minInt;
133 static const Int maxInt;
134 static const UInt maxUInt;
137 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
138 # ifndef JSON_VALUE_USE_INTERNAL_MAP
142 enum DuplicationPolicy
148 CZString( ArrayIndex index );
149 CZString( const char *cstr, DuplicationPolicy allocate );
150 CZString( const CZString &other );
152 CZString &operator =( const CZString &other );
153 bool operator<( const CZString &other ) const;
154 bool operator==( const CZString &other ) const;
155 ArrayIndex index() const;
156 const char *c_str() const;
157 bool isStaticString() const;
159 void swap( CZString &other );
165 # ifndef JSON_USE_CPPTL_SMALLMAP
166 typedef std::map<CZString, Value> ObjectValues;
168 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
169 # endif // ifndef JSON_USE_CPPTL_SMALLMAP
170 # endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
171 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
174 /** \brief Create a default Value of the given type.
176 This is a very useful constructor.
177 To create an empty array, pass arrayValue.
178 To create an empty object, pass objectValue.
179 Another Value can then be set to this one by assignment.
180 This is useful since clear() and resize() will not alter types.
184 Json::Value null_value; // null
185 Json::Value arr_value(Json::arrayValue); // []
186 Json::Value obj_value(Json::objectValue); // {}
189 Value( ValueType type = nullValue );
190 #if !defined(JSON_NO_INT64)
192 Value( ArrayIndex value );
193 #endif // if !defined(JSON_NO_INT64)
196 Value( double value );
197 Value( const char *value );
198 Value( const char *beginValue, const char *endValue );
199 /** \brief Constructs a value from a static string.
201 * Like other value string constructor but do not duplicate the string for
202 * internal storage. The given string must remain alive after the call to this
206 * Json::Value aValue( StaticString("some text") );
209 Value( const StaticString &value );
210 Value( const std::string &value );
211 # ifdef JSON_USE_CPPTL
212 Value( const CppTL::ConstString &value );
215 Value( const Value &other );
218 Value &operator=( const Value &other );
220 /// \note Currently, comments are intentionally not swapped, for
221 /// both logic and efficiency.
222 void swap( Value &other );
224 ValueType type() const;
226 bool operator <( const Value &other ) const;
227 bool operator <=( const Value &other ) const;
228 bool operator >=( const Value &other ) const;
229 bool operator >( const Value &other ) const;
231 bool operator ==( const Value &other ) const;
232 bool operator !=( const Value &other ) const;
234 int compare( const Value &other );
236 const char *asCString() const;
237 std::string asString() const;
238 # ifdef JSON_USE_CPPTL
239 CppTL::ConstString asConstString() const;
243 double asDouble() const;
250 bool isIntegral() const;
251 bool isDouble() const;
252 bool isNumeric() const;
253 bool isString() const;
254 bool isArray() const;
255 bool isObject() const;
257 bool isConvertibleTo( ValueType other ) const;
259 /// Number of values in array or object
260 ArrayIndex size() const;
262 /// \brief Return true if empty array, empty object, or null;
263 /// otherwise, false.
267 bool operator!() const;
269 /// Remove all object members and array elements.
270 /// \pre type() is arrayValue, objectValue, or nullValue
271 /// \post type() is unchanged
274 /// Resize the array to size elements.
275 /// New elements are initialized to null.
276 /// May only be called on nullValue or arrayValue.
277 /// \pre type() is arrayValue or nullValue
278 /// \post type() is arrayValue
279 void resize( ArrayIndex size );
281 /// Access an array element (zero based index ).
282 /// If the array contains less than index element, then null value are inserted
283 /// in the array so that its size is index+1.
284 /// (You may need to say 'value[0u]' to get your compiler to distinguish
285 /// this from the operator[] which takes a string.)
286 Value &operator[]( ArrayIndex index );
287 /// Access an array element (zero based index )
288 /// (You may need to say 'value[0u]' to get your compiler to distinguish
289 /// this from the operator[] which takes a string.)
290 const Value &operator[]( ArrayIndex index ) const;
291 /// If the array contains at least index+1 elements, returns the element value,
292 /// otherwise returns defaultValue.
293 Value get( ArrayIndex index,
294 const Value &defaultValue ) const;
295 /// Return true if index < size().
296 bool isValidIndex( ArrayIndex index ) const;
297 /// \brief Append value to array at the end.
299 /// Equivalent to jsonvalue[jsonvalue.size()] = value;
300 Value &append( const Value &value );
302 /// Access an object value by name, create a null member if it does not exist.
303 Value &operator[]( const char *key );
304 /// Access an object value by name, returns null if there is no member with that name.
305 const Value &operator[]( const char *key ) const;
306 /// Access an object value by name, create a null member if it does not exist.
307 Value &operator[]( const std::string &key );
308 /// Access an object value by name, returns null if there is no member with that name.
309 const Value &operator[]( const std::string &key ) const;
310 /** \brief Access an object value by name, create a null member if it does not exist.
312 * If the object as no entry for that name, then the member name used to store
313 * the new entry is not duplicated.
316 * Json::Value object;
317 * static const StaticString code("code");
318 * object[code] = 1234;
321 Value &operator[]( const StaticString &key );
322 # ifdef JSON_USE_CPPTL
323 /// Access an object value by name, create a null member if it does not exist.
324 Value &operator[]( const CppTL::ConstString &key );
325 /// Access an object value by name, returns null if there is no member with that name.
326 const Value &operator[]( const CppTL::ConstString &key ) const;
328 /// Return the member named key if it exist, defaultValue otherwise.
329 Value get( const char *key,
330 const Value &defaultValue ) const;
331 /// Return the member named key if it exist, defaultValue otherwise.
332 Value get( const std::string &key,
333 const Value &defaultValue ) const;
334 # ifdef JSON_USE_CPPTL
335 /// Return the member named key if it exist, defaultValue otherwise.
336 Value get( const CppTL::ConstString &key,
337 const Value &defaultValue ) const;
339 /// \brief Remove and return the named member.
341 /// Do nothing if it did not exist.
342 /// \return the removed Value, or null.
343 /// \pre type() is objectValue or nullValue
344 /// \post type() is unchanged
345 Value removeMember( const char* key );
346 /// Same as removeMember(const char*)
347 Value removeMember( const std::string &key );
349 /// Return true if the object has a member named key.
350 bool isMember( const char *key ) const;
351 /// Return true if the object has a member named key.
352 bool isMember( const std::string &key ) const;
353 # ifdef JSON_USE_CPPTL
354 /// Return true if the object has a member named key.
355 bool isMember( const CppTL::ConstString &key ) const;
358 /// \brief Return a list of the member names.
360 /// If null, return an empty list.
361 /// \pre type() is objectValue or nullValue
362 /// \post if type() was nullValue, it remains nullValue
363 Members getMemberNames() const;
365 //# ifdef JSON_USE_CPPTL
366 // EnumMemberNames enumMemberNames() const;
367 // EnumValues enumValues() const;
370 /// Comments must be //... or /* ... */
371 void setComment( const char *comment,
372 CommentPlacement placement );
373 /// Comments must be //... or /* ... */
374 void setComment( const std::string &comment,
375 CommentPlacement placement );
376 bool hasComment( CommentPlacement placement ) const;
377 /// Include delimiters and embedded newlines.
378 std::string getComment( CommentPlacement placement ) const;
380 std::string toStyledString() const;
382 const_iterator begin() const;
383 const_iterator end() const;
389 Value &resolveReference( const char *key,
392 # ifdef JSON_VALUE_USE_INTERNAL_MAP
393 inline bool isItemAvailable() const
395 return itemIsUsed_ == 0;
398 inline void setItemUsed( bool isUsed = true )
400 itemIsUsed_ = isUsed ? 1 : 0;
403 inline bool isMemberNameStatic() const
405 return memberNameIsStatic_ == 0;
408 inline void setMemberNameIsStatic( bool isStatic )
410 memberNameIsStatic_ = isStatic ? 1 : 0;
412 # endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
420 void setComment( const char *text );
425 //struct MemberNamesTransform
427 // typedef const char *result_type;
428 // const char *operator()( const CZString &name ) const
430 // return name.c_str();
441 # ifdef JSON_VALUE_USE_INTERNAL_MAP
442 ValueInternalArray *array_;
443 ValueInternalMap *map_;
449 int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
450 # ifdef JSON_VALUE_USE_INTERNAL_MAP
451 unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
452 int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
454 CommentInfo *comments_;
458 /** \brief Experimental and untested: represents an element of the "path" to access a node.
466 PathArgument( ArrayIndex index );
467 PathArgument( const char *key );
468 PathArgument( const std::string &key );
482 /** \brief Experimental and untested: represents a "path" to access a node.
486 * - ".[n]" => elements at index 'n' of root node (an array value)
487 * - ".name" => member named 'name' of root node (an object value)
488 * - ".name1.name2.name3"
489 * - ".[0][1][2].name1[3]"
490 * - ".%" => member name is provided as parameter
491 * - ".[%]" => index is provied as parameter
496 Path( const std::string &path,
497 const PathArgument &a1 = PathArgument(),
498 const PathArgument &a2 = PathArgument(),
499 const PathArgument &a3 = PathArgument(),
500 const PathArgument &a4 = PathArgument(),
501 const PathArgument &a5 = PathArgument() );
503 const Value &resolve( const Value &root ) const;
504 Value resolve( const Value &root,
505 const Value &defaultValue ) const;
506 /// Creates the "path" to access the specified node and returns a reference on the node.
507 Value &make( Value &root ) const;
510 typedef std::vector<const PathArgument *> InArgs;
511 typedef std::vector<PathArgument> Args;
513 void makePath( const std::string &path,
515 void addPathInArg( const std::string &path,
517 InArgs::const_iterator &itInArg,
518 PathArgument::Kind kind );
519 void invalidPath( const std::string &path,
527 #ifdef JSON_VALUE_USE_INTERNAL_MAP
528 /** \brief Allocator to customize Value internal map.
529 * Below is an example of a simple implementation (default implementation actually
530 * use memory pool for speed).
532 class DefaultValueMapAllocator : public ValueMapAllocator
534 public: // overridden from ValueMapAllocator
535 virtual ValueInternalMap *newMap()
537 return new ValueInternalMap();
540 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
542 return new ValueInternalMap( other );
545 virtual void destructMap( ValueInternalMap *map )
550 virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
552 return new ValueInternalLink[size];
555 virtual void releaseMapBuckets( ValueInternalLink *links )
560 virtual ValueInternalLink *allocateMapLink()
562 return new ValueInternalLink();
565 virtual void releaseMapLink( ValueInternalLink *link )
572 class JSON_API ValueMapAllocator
575 virtual ~ValueMapAllocator();
576 virtual ValueInternalMap *newMap() = 0;
577 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
578 virtual void destructMap( ValueInternalMap *map ) = 0;
579 virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
580 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
581 virtual ValueInternalLink *allocateMapLink() = 0;
582 virtual void releaseMapLink( ValueInternalLink *link ) = 0;
585 /** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
586 * \internal previous_ & next_ allows for bidirectional traversal.
588 class JSON_API ValueInternalLink
591 enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
599 ~ValueInternalLink();
601 Value items_[itemPerLink];
602 char *keys_[itemPerLink];
603 ValueInternalLink *previous_;
604 ValueInternalLink *next_;
608 /** \brief A linked page based hash-table implementation used internally by Value.
609 * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
610 * list in each bucket to handle collision. There is an addional twist in that
611 * each node of the collision linked list is a page containing a fixed amount of
612 * value. This provides a better compromise between memory usage and speed.
614 * Each bucket is made up of a chained list of ValueInternalLink. The last
615 * link of a given bucket can be found in the 'previous_' field of the following bucket.
616 * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
617 * Only the last link of a bucket may contains 'available' item. The last link always
618 * contains at least one element unless is it the bucket one very first link.
620 class JSON_API ValueInternalMap
622 friend class ValueIteratorBase;
625 typedef unsigned int HashKey;
626 typedef unsigned int BucketIndex;
628 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
638 ValueInternalMap *map_;
639 ValueInternalLink *link_;
640 BucketIndex itemIndex_;
641 BucketIndex bucketIndex_;
643 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
646 ValueInternalMap( const ValueInternalMap &other );
647 ValueInternalMap &operator =( const ValueInternalMap &other );
650 void swap( ValueInternalMap &other );
652 BucketIndex size() const;
656 bool reserveDelta( BucketIndex growth );
658 bool reserve( BucketIndex newItemCount );
660 const Value *find( const char *key ) const;
662 Value *find( const char *key );
664 Value &resolveReference( const char *key,
667 void remove( const char *key );
669 void doActualRemove( ValueInternalLink *link,
671 BucketIndex bucketIndex );
673 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
675 Value &setNewItem( const char *key,
677 ValueInternalLink *link,
680 Value &unsafeAdd( const char *key,
684 HashKey hash( const char *key ) const;
686 int compare( const ValueInternalMap &other ) const;
689 void makeBeginIterator( IteratorState &it ) const;
690 void makeEndIterator( IteratorState &it ) const;
691 static bool equals( const IteratorState &x, const IteratorState &other );
692 static void increment( IteratorState &iterator );
693 static void incrementBucket( IteratorState &iterator );
694 static void decrement( IteratorState &iterator );
695 static const char *key( const IteratorState &iterator );
696 static const char *key( const IteratorState &iterator, bool &isStatic );
697 static Value &value( const IteratorState &iterator );
698 static int distance( const IteratorState &x, const IteratorState &y );
701 ValueInternalLink *buckets_;
702 ValueInternalLink *tailLink_;
703 BucketIndex bucketsSize_;
704 BucketIndex itemCount_;
707 /** \brief A simplified deque implementation used internally by Value.
709 * It is based on a list of fixed "page", each page contains a fixed number of items.
710 * Instead of using a linked-list, a array of pointer is used for fast item look-up.
711 * Look-up for an element is as follow:
712 * - compute page index: pageIndex = itemIndex / itemsPerPage
713 * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
715 * Insertion is amortized constant time (only the array containing the index of pointers
716 * need to be reallocated when items are appended).
718 class JSON_API ValueInternalArray
721 friend class ValueIteratorBase;
723 enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.
724 typedef Value::ArrayIndex ArrayIndex;
725 typedef unsigned int PageIndex;
727 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
728 struct IteratorState // Must be a POD
732 , currentPageIndex_(0)
733 , currentItemIndex_(0)
736 ValueInternalArray *array_;
737 Value **currentPageIndex_;
738 unsigned int currentItemIndex_;
740 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
742 ValueInternalArray();
743 ValueInternalArray( const ValueInternalArray &other );
744 ValueInternalArray &operator =( const ValueInternalArray &other );
745 ~ValueInternalArray();
746 void swap( ValueInternalArray &other );
749 void resize( ArrayIndex newSize );
751 Value &resolveReference( ArrayIndex index );
753 Value *find( ArrayIndex index ) const;
755 ArrayIndex size() const;
757 int compare( const ValueInternalArray &other ) const;
760 static bool equals( const IteratorState &x, const IteratorState &other );
761 static void increment( IteratorState &iterator );
762 static void decrement( IteratorState &iterator );
763 static Value &dereference( const IteratorState &iterator );
764 static Value &unsafeDereference( const IteratorState &iterator );
765 static int distance( const IteratorState &x, const IteratorState &y );
766 static ArrayIndex indexOf( const IteratorState &iterator );
767 void makeBeginIterator( IteratorState &it ) const;
768 void makeEndIterator( IteratorState &it ) const;
769 void makeIterator( IteratorState &it, ArrayIndex index ) const;
771 void makeIndexValid( ArrayIndex index );
775 PageIndex pageCount_;
778 /** \brief Experimental: do not use. Allocator to customize Value internal array.
779 * Below is an example of a simple implementation (actual implementation use
782 class DefaultValueArrayAllocator : public ValueArrayAllocator
784 public: // overridden from ValueArrayAllocator
785 virtual ~DefaultValueArrayAllocator()
789 virtual ValueInternalArray *newArray()
791 return new ValueInternalArray();
794 virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
796 return new ValueInternalArray( other );
799 virtual void destruct( ValueInternalArray *array )
804 virtual void reallocateArrayPageIndex( Value **&indexes,
805 ValueInternalArray::PageIndex &indexCount,
806 ValueInternalArray::PageIndex minNewIndexCount )
808 ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
809 if ( minNewIndexCount > newIndexCount )
810 newIndexCount = minNewIndexCount;
811 void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
813 throw std::bad_alloc();
814 indexCount = newIndexCount;
815 indexes = static_cast<Value **>( newIndexes );
817 virtual void releaseArrayPageIndex( Value **indexes,
818 ValueInternalArray::PageIndex indexCount )
824 virtual Value *allocateArrayPage()
826 return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
829 virtual void releaseArrayPage( Value *value )
837 class JSON_API ValueArrayAllocator
840 virtual ~ValueArrayAllocator();
841 virtual ValueInternalArray *newArray() = 0;
842 virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;
843 virtual void destructArray( ValueInternalArray *array ) = 0;
844 /** \brief Reallocate array page index.
845 * Reallocates an array of pointer on each page.
846 * \param indexes [input] pointer on the current index. May be \c NULL.
847 * [output] pointer on the new index of at least
848 * \a minNewIndexCount pages.
849 * \param indexCount [input] current number of pages in the index.
850 * [output] number of page the reallocated index can handle.
851 * \b MUST be >= \a minNewIndexCount.
852 * \param minNewIndexCount Minimum number of page the new index must be able to
855 virtual void reallocateArrayPageIndex( Value **&indexes,
856 ValueInternalArray::PageIndex &indexCount,
857 ValueInternalArray::PageIndex minNewIndexCount ) = 0;
858 virtual void releaseArrayPageIndex( Value **indexes,
859 ValueInternalArray::PageIndex indexCount ) = 0;
860 virtual Value *allocateArrayPage() = 0;
861 virtual void releaseArrayPage( Value *value ) = 0;
863 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
866 /** \brief base class for Value iterators.
869 class ValueIteratorBase
872 typedef unsigned int size_t;
873 typedef int difference_type;
874 typedef ValueIteratorBase SelfType;
877 #ifndef JSON_VALUE_USE_INTERNAL_MAP
878 explicit ValueIteratorBase( const Value::ObjectValues::iterator ¤t );
880 ValueIteratorBase( const ValueInternalArray::IteratorState &state );
881 ValueIteratorBase( const ValueInternalMap::IteratorState &state );
884 bool operator ==( const SelfType &other ) const
886 return isEqual( other );
889 bool operator !=( const SelfType &other ) const
891 return !isEqual( other );
894 difference_type operator -( const SelfType &other ) const
896 return computeDistance( other );
899 /// Return either the index or the member name of the referenced value as a Value.
902 /// Return the index of the referenced Value. -1 if it is not an arrayValue.
905 /// Return the member name of the referenced Value. "" if it is not an objectValue.
906 const char *memberName() const;
909 Value &deref() const;
915 difference_type computeDistance( const SelfType &other ) const;
917 bool isEqual( const SelfType &other ) const;
919 void copy( const SelfType &other );
922 #ifndef JSON_VALUE_USE_INTERNAL_MAP
923 Value::ObjectValues::iterator current_;
924 // Indicates that iterator is for a null value.
929 ValueInternalArray::IteratorState array_;
930 ValueInternalMap::IteratorState map_;
936 /** \brief const iterator for object and array value.
939 class ValueConstIterator : public ValueIteratorBase
943 typedef unsigned int size_t;
944 typedef int difference_type;
945 typedef const Value &reference;
946 typedef const Value *pointer;
947 typedef ValueConstIterator SelfType;
949 ValueConstIterator();
951 /*! \internal Use by Value to create an iterator.
953 #ifndef JSON_VALUE_USE_INTERNAL_MAP
954 explicit ValueConstIterator( const Value::ObjectValues::iterator ¤t );
956 ValueConstIterator( const ValueInternalArray::IteratorState &state );
957 ValueConstIterator( const ValueInternalMap::IteratorState &state );
960 SelfType &operator =( const ValueIteratorBase &other );
962 SelfType operator++( int )
964 SelfType temp( *this );
969 SelfType operator--( int )
971 SelfType temp( *this );
976 SelfType &operator--()
982 SelfType &operator++()
988 reference operator *() const
995 /** \brief Iterator for object and array value.
997 class ValueIterator : public ValueIteratorBase
1001 typedef unsigned int size_t;
1002 typedef int difference_type;
1003 typedef Value &reference;
1004 typedef Value *pointer;
1005 typedef ValueIterator SelfType;
1008 ValueIterator( const ValueConstIterator &other );
1009 ValueIterator( const ValueIterator &other );
1011 /*! \internal Use by Value to create an iterator.
1013 #ifndef JSON_VALUE_USE_INTERNAL_MAP
1014 explicit ValueIterator( const Value::ObjectValues::iterator ¤t );
1016 ValueIterator( const ValueInternalArray::IteratorState &state );
1017 ValueIterator( const ValueInternalMap::IteratorState &state );
1021 SelfType &operator =( const SelfType &other );
1023 SelfType operator++( int )
1025 SelfType temp( *this );
1030 SelfType operator--( int )
1032 SelfType temp( *this );
1037 SelfType &operator--()
1043 SelfType &operator++()
1049 reference operator *() const
1059 #endif // CPPTL_JSON_H_INCLUDED