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
144 CZString(
const char *cstr, DuplicationPolicy allocate );
151 const char *c_str()
const;
152 bool isStaticString()
const;
160 # ifndef JSON_USE_CPPTL_SMALLMAP
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;
248 bool isConvertibleTo(
ValueType other )
const;
258 bool operator!()
const;
285 const Value &defaultValue )
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,
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,
533 unsigned int length =
unknown ) = 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_;
632 friend class ValueIteratorBase;
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 );
687 ValueInternalLink *
link,
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_;
731 friend class ValueIteratorBase;
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
1023 #ifndef JSON_VALUE_USE_INTERNAL_MAP
1026 ValueIterator(
const ValueInternalArray::IteratorState &state );
1027 ValueIterator(
const ValueInternalMap::IteratorState &state );
1069 #endif // CPPTL_JSON_H_INCLUDED
void swap(ora::Record &rh, ora::Record &lh)
std::vector< std::string > Members
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
virtual char * duplicateStringValue(const char *value, unsigned int length=unknown)=0
void compare(std::vector< std::string > const &old_files, std::string const &old_process, std::vector< std::string > const &new_files, std::string const &new_process, unsigned int max_events, bool ignore_prescales, int verbose)
void addPathInArg(const std::string &path, const InArgs &in, InArgs::const_iterator &itInArg, PathArgument::Kind kind)
Experimental and untested: represents an element of the "path" to access a node.
bool operator>(l1t::Jet &a, l1t::Jet &b)
void makePath(const std::string &path, const InArgs &in)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
std::vector< const PathArgument * > InArgs
Lightweight wrapper to tag static string.
ValueConstIterator const_iterator
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
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
const Value & resolve(const Value &root) const
a comment placed on the line before a value
virtual ~ValueAllocator()
bool operator<=(View< T > const &, View< T > const &)
bool operator>=(View< T > const &, View< T > const &)
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
tuple path
else: Piece not in the list, fine.
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).
T operator[](int i) const
reco::JetExtendedAssociation::JetExtendedData Value
ValueType
Type of the value held by a Value object.
void invalidPath(const std::string &path, int location)
ValueIteratorBase SelfType
a comment just after a value on the same line
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
base class for Value iterators.
Path(const std::string &path, const PathArgument &a1=PathArgument(), const PathArgument &a2=PathArgument(), const PathArgument &a3=PathArgument(), const PathArgument &a4=PathArgument(), const PathArgument &a5=PathArgument())
a comment on the line after a value (only make sense for root value)
virtual void releaseStringValue(char *value)=0
virtual void releaseMemberName(char *memberName)=0
StaticString(const char *czstring)
virtual char * makeMemberName(const char *memberName)=0
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.
tuple size
Write out results.
Value::ObjectValues::iterator current_
array value (ordered list)
string root
initialization
static bool isBool(std::string value)