1 #ifndef CPPTL_JSON_H_INCLUDED 2 # define CPPTL_JSON_H_INCLUDED 8 # ifndef JSON_USE_CPPTL_SMALLMAP 11 # include <cpptl/smallmap.h> 13 # ifdef JSON_USE_CPPTL 14 # include <cpptl/forwards.h> 70 operator const char *()
const 114 # ifdef JSON_VALUE_USE_INTERNAL_MAP 115 friend class ValueInternalLink;
116 friend class ValueInternalMap;
132 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 133 # ifndef JSON_VALUE_USE_INTERNAL_MAP 151 const char *c_str()
const;
152 bool isStaticString()
const;
160 # ifndef JSON_USE_CPPTL_SMALLMAP 163 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
164 # endif // ifndef JSON_USE_CPPTL_SMALLMAP 165 # endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 166 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 189 Value(
const char *beginValue,
const char *endValue );
202 # ifdef JSON_USE_CPPTL 227 const char *asCString()
const;
229 # ifdef JSON_USE_CPPTL 230 CppTL::ConstString asConstString()
const;
234 double asDouble()
const;
241 bool isIntegral()
const;
242 bool isDouble()
const;
243 bool isNumeric()
const;
244 bool isString()
const;
245 bool isArray()
const;
246 bool isObject()
const;
258 bool operator!()
const;
270 void resize( UInt
size );
285 const Value &defaultValue )
const;
287 bool isValidIndex( UInt index )
const;
313 # ifdef JSON_USE_CPPTL 321 const Value &defaultValue )
const;
324 const Value &defaultValue )
const;
325 # ifdef JSON_USE_CPPTL 326 Value get(
const CppTL::ConstString &
key,
328 const Value &defaultValue )
const;
330 Value removeMember(
const char* key );
341 bool isMember(
const char *key )
const;
344 # ifdef JSON_USE_CPPTL 345 bool isMember(
const CppTL::ConstString &key )
const;
354 Members getMemberNames()
const;
362 void setComment(
const char *
comment,
373 const_iterator
begin()
const;
374 const_iterator
end()
const;
380 Value &resolveReference(
const char *key,
383 # ifdef JSON_VALUE_USE_INTERNAL_MAP 384 inline bool isItemAvailable()
const 386 return itemIsUsed_ == 0;
389 inline void setItemUsed(
bool isUsed =
true )
391 itemIsUsed_ = isUsed ? 1 : 0;
394 inline bool isMemberNameStatic()
const 396 return memberNameIsStatic_ == 0;
399 inline void setMemberNameIsStatic(
bool isStatic )
401 memberNameIsStatic_ = isStatic ? 1 : 0;
403 # endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 411 void setComment(
const char *
text );
432 # ifdef JSON_VALUE_USE_INTERNAL_MAP 433 ValueInternalArray *array_;
434 ValueInternalMap *
map_;
441 # ifdef JSON_VALUE_USE_INTERNAL_MAP 442 unsigned int itemIsUsed_ : 1;
443 int memberNameIsStatic_ : 1;
496 const Value &defaultValue )
const;
501 typedef std::vector<const PathArgument *>
InArgs;
502 typedef std::vector<PathArgument>
Args;
508 InArgs::const_iterator &itInArg,
530 virtual char *makeMemberName(
const char *memberName )
const = 0;
531 virtual void releaseMemberName(
char *memberName )
const = 0;
532 virtual char *duplicateStringValue(
const char *
value,
533 unsigned int length =
unknown )
const = 0;
534 virtual void releaseStringValue(
char *value )
const = 0;
537 #ifdef JSON_VALUE_USE_INTERNAL_MAP 585 virtual ~ValueMapAllocator();
586 virtual ValueInternalMap *newMap() = 0;
587 virtual ValueInternalMap *newMapCopy(
const ValueInternalMap &
other ) = 0;
588 virtual void destructMap( ValueInternalMap *
map ) = 0;
589 virtual ValueInternalLink *allocateMapBuckets(
unsigned int size ) = 0;
590 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
591 virtual ValueInternalLink *allocateMapLink() = 0;
592 virtual void releaseMapLink( ValueInternalLink *link ) = 0;
601 enum { itemPerLink = 6 };
609 ~ValueInternalLink();
611 Value items_[itemPerLink];
612 char *keys_[itemPerLink];
613 ValueInternalLink *previous_;
614 ValueInternalLink *next_;
635 typedef unsigned int HashKey;
636 typedef unsigned int BucketIndex;
638 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 648 ValueInternalMap *
map_;
649 ValueInternalLink *link_;
650 BucketIndex itemIndex_;
651 BucketIndex bucketIndex_;
653 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 656 ValueInternalMap(
const ValueInternalMap &
other );
657 ValueInternalMap &operator =(
const ValueInternalMap &other );
660 void swap( ValueInternalMap &other );
662 BucketIndex
size()
const;
666 bool reserveDelta( BucketIndex growth );
668 bool reserve( BucketIndex newItemCount );
674 Value &resolveReference(
const char *key,
677 void remove(
const char *
key );
679 void doActualRemove( ValueInternalLink *link,
681 BucketIndex bucketIndex );
683 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
685 Value &setNewItem(
const char *key,
687 ValueInternalLink *link,
690 Value &unsafeAdd(
const char *key,
694 HashKey
hash(
const char *key )
const;
696 int compare(
const ValueInternalMap &other )
const;
699 void makeBeginIterator( IteratorState &it )
const;
700 void makeEndIterator( IteratorState &it )
const;
701 static bool equals(
const IteratorState &
x,
const IteratorState &other );
702 static void increment( IteratorState &iterator );
703 static void incrementBucket( IteratorState &iterator );
704 static void decrement( IteratorState &iterator );
705 static const char *
key(
const IteratorState &iterator );
706 static const char *
key(
const IteratorState &iterator,
bool &isStatic );
707 static Value &
value(
const IteratorState &iterator );
708 static int distance(
const IteratorState &x,
const IteratorState &y );
711 ValueInternalLink *buckets_;
712 ValueInternalLink *tailLink_;
713 BucketIndex bucketsSize_;
714 BucketIndex itemCount_;
733 enum { itemsPerPage = 8 };
735 typedef unsigned int PageIndex;
737 # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 742 , currentPageIndex_(0)
743 , currentItemIndex_(0)
746 ValueInternalArray *array_;
747 Value **currentPageIndex_;
748 unsigned int currentItemIndex_;
750 # endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 752 ValueInternalArray();
753 ValueInternalArray(
const ValueInternalArray &
other );
754 ValueInternalArray &operator =(
const ValueInternalArray &other );
755 ~ValueInternalArray();
756 void swap( ValueInternalArray &other );
759 void resize( ArrayIndex newSize );
765 ArrayIndex
size()
const;
767 int compare(
const ValueInternalArray &other )
const;
770 static bool equals(
const IteratorState &
x,
const IteratorState &other );
771 static void increment( IteratorState &iterator );
772 static void decrement( IteratorState &iterator );
773 static Value &dereference(
const IteratorState &iterator );
774 static Value &unsafeDereference(
const IteratorState &iterator );
775 static int distance(
const IteratorState &x,
const IteratorState &y );
776 static ArrayIndex indexOf(
const IteratorState &iterator );
777 void makeBeginIterator( IteratorState &it )
const;
778 void makeEndIterator( IteratorState &it )
const;
779 void makeIterator( IteratorState &it, ArrayIndex index )
const;
781 void makeIndexValid( ArrayIndex index );
785 PageIndex pageCount_;
850 virtual ~ValueArrayAllocator();
851 virtual ValueInternalArray *newArray() = 0;
852 virtual ValueInternalArray *newArrayCopy(
const ValueInternalArray &
other ) = 0;
853 virtual void destructArray( ValueInternalArray *
array ) = 0;
865 virtual void reallocateArrayPageIndex(
Value **&indexes,
866 ValueInternalArray::PageIndex &indexCount,
867 ValueInternalArray::PageIndex minNewIndexCount ) = 0;
868 virtual void releaseArrayPageIndex(
Value **indexes,
869 ValueInternalArray::PageIndex indexCount ) = 0;
870 virtual Value *allocateArrayPage() = 0;
871 virtual void releaseArrayPage(
Value *
value ) = 0;
873 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 887 #ifndef JSON_VALUE_USE_INTERNAL_MAP 896 return isEqual( other );
901 return !isEqual( other );
906 return computeDistance( other );
916 const char *memberName()
const;
919 Value &deref()
const;
925 difference_type computeDistance(
const SelfType &
other )
const;
927 bool isEqual(
const SelfType &other )
const;
929 void copy(
const SelfType &other );
932 #ifndef JSON_VALUE_USE_INTERNAL_MAP 939 ValueInternalArray::IteratorState array_;
940 ValueInternalMap::IteratorState
map_;
963 #ifndef JSON_VALUE_USE_INTERNAL_MAP 974 SelfType
temp( *
this );
981 SelfType
temp( *
this );
1023 #ifndef JSON_VALUE_USE_INTERNAL_MAP 1024 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t );
1026 ValueIterator(
const ValueInternalArray::IteratorState &state );
1027 ValueIterator(
const ValueInternalMap::IteratorState &state );
1031 SelfType &operator =(
const SelfType &
other );
1035 SelfType
temp( *
this );
1042 SelfType
temp( *
this );
1069 #endif // CPPTL_JSON_H_INCLUDED
bool compare(const P &i, const P &j)
std::vector< std::string > Members
Experimental and untested: represents an element of the "path" to access a node.
S make(const edm::ParameterSet &cfg)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
std::vector< const PathArgument * > InArgs
Lightweight wrapper to tag static string.
ValueConstIterator const_iterator
static const UInt maxUInt
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const char * c_str() const
a comment placed on the line before a value
void swap(Association< C > &lhs, Association< C > &rhs)
bool operator<=(View< T > const &, View< T > const &)
T x() const
Cartesian x coordinate.
bool operator>=(View< T > const &, View< T > const &)
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
std::map< CZString, Value > ObjectValues
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
ValueConstIterator SelfType
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
object value (collection of name/value pairs).
bool operator>(View< T > const &, View< T > const &)
T operator[](int i) const
reco::JetExtendedAssociation::JetExtendedData Value
ValueType
Type of the value held by a Value object.
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
a comment just after a value on the same line
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
base class for Value iterators.
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
a comment on the line after a value (only make sense for root value)
StaticString(const char *czstring)
std::vector< PathArgument > Args
Experimental do not use: Allocator to customize member name and string value memory management done b...
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Iterator for object and array value.
Experimental and untested: represents a "path" to access a node.
const iterator for object and array value.
Value::ObjectValues::iterator current_
array value (ordered list)
static bool isBool(std::string value)