1 #ifndef CPPTL_JSON_H_INCLUDED 2 #define CPPTL_JSON_H_INCLUDED 8 #ifndef JSON_USE_CPPTL_SMALLMAP 11 #include <cpptl/smallmap.h> 14 #include <cpptl/forwards.h> 66 operator const char *()
const {
return str_; }
68 const char *
c_str()
const {
return str_; }
103 #ifdef JSON_VALUE_USE_INTERNAL_MAP 104 friend class ValueInternalLink;
105 friend class ValueInternalMap;
121 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 122 #ifndef JSON_VALUE_USE_INTERNAL_MAP 127 CZString(
const char *cstr, DuplicationPolicy allocate);
134 const char *c_str()
const;
135 bool isStaticString()
const;
144 #ifndef JSON_USE_CPPTL_SMALLMAP 148 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 149 #endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 150 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 173 Value(
const char *beginValue,
const char *endValue);
186 #ifdef JSON_USE_CPPTL 211 const char *asCString()
const;
213 #ifdef JSON_USE_CPPTL 214 CppTL::ConstString asConstString()
const;
218 double asDouble()
const;
225 bool isIntegral()
const;
226 bool isDouble()
const;
227 bool isNumeric()
const;
228 bool isString()
const;
229 bool isArray()
const;
230 bool isObject()
const;
242 bool operator!()
const;
254 void resize(
UInt size);
296 #ifdef JSON_USE_CPPTL 306 #ifdef JSON_USE_CPPTL 310 Value removeMember(
const char *
key);
321 bool isMember(
const char *
key)
const;
324 #ifdef JSON_USE_CPPTL 325 bool isMember(
const CppTL::ConstString &
key)
const;
334 Members getMemberNames()
const;
358 Value &resolveReference(
const char *
key,
bool isStatic);
360 #ifdef JSON_VALUE_USE_INTERNAL_MAP 361 inline bool isItemAvailable()
const {
return itemIsUsed_ == 0; }
363 inline void setItemUsed(
bool isUsed =
true) { itemIsUsed_ = isUsed ? 1 : 0; }
365 inline bool isMemberNameStatic()
const {
return memberNameIsStatic_ == 0; }
367 inline void setMemberNameIsStatic(
bool isStatic) { memberNameIsStatic_ = isStatic ? 1 : 0; }
368 #endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 375 void setComment(
const char *
text);
395 #ifdef JSON_VALUE_USE_INTERNAL_MAP 396 ValueInternalArray *array_;
397 ValueInternalMap *map_;
404 #ifdef JSON_VALUE_USE_INTERNAL_MAP 405 unsigned int itemIsUsed_ : 1;
406 int memberNameIsStatic_ : 1;
455 typedef std::vector<const PathArgument *>
InArgs;
456 typedef std::vector<PathArgument>
Args;
461 InArgs::const_iterator &itInArg,
487 #ifdef JSON_VALUE_USE_INTERNAL_MAP 534 virtual ~ValueMapAllocator();
535 virtual ValueInternalMap *newMap() = 0;
536 virtual ValueInternalMap *newMapCopy(
const ValueInternalMap &
other) = 0;
537 virtual void destructMap(ValueInternalMap *
map) = 0;
538 virtual ValueInternalLink *allocateMapBuckets(
unsigned int size) = 0;
539 virtual void releaseMapBuckets(ValueInternalLink *
links) = 0;
540 virtual ValueInternalLink *allocateMapLink() = 0;
541 virtual void releaseMapLink(ValueInternalLink *link) = 0;
549 enum { itemPerLink = 6 };
550 enum InternalFlags { flagAvailable = 0, flagUsed = 1 };
554 ~ValueInternalLink();
556 Value items_[itemPerLink];
557 char *keys_[itemPerLink];
558 ValueInternalLink *previous_;
559 ValueInternalLink *next_;
575 friend class ValueIteratorBase;
579 typedef unsigned int HashKey;
580 typedef unsigned int BucketIndex;
582 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 583 struct IteratorState {
584 IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}
585 ValueInternalMap *map_;
586 ValueInternalLink *link_;
587 BucketIndex itemIndex_;
588 BucketIndex bucketIndex_;
590 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 593 ValueInternalMap(
const ValueInternalMap &
other);
599 BucketIndex
size()
const;
603 bool reserveDelta(BucketIndex growth);
605 bool reserve(BucketIndex newItemCount);
611 Value &resolveReference(
const char *
key,
bool isStatic);
613 void remove(
const char *
key);
615 void doActualRemove(ValueInternalLink *link, BucketIndex
index, BucketIndex bucketIndex);
617 ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);
619 Value &setNewItem(
const char *
key,
bool isStatic, ValueInternalLink *link, BucketIndex
index);
621 Value &unsafeAdd(
const char *
key,
bool isStatic, HashKey hashedKey);
623 HashKey
hash(
const char *
key)
const;
628 void makeBeginIterator(IteratorState &
it)
const;
629 void makeEndIterator(IteratorState &
it)
const;
630 static bool equals(
const IteratorState &x,
const IteratorState &
other);
631 static void increment(IteratorState &iterator);
632 static void incrementBucket(IteratorState &iterator);
633 static void decrement(IteratorState &iterator);
634 static const char *
key(
const IteratorState &iterator);
635 static const char *
key(
const IteratorState &iterator,
bool &isStatic);
636 static Value &
value(
const IteratorState &iterator);
637 static int distance(
const IteratorState &x,
const IteratorState &y);
640 ValueInternalLink *buckets_;
641 ValueInternalLink *tailLink_;
642 BucketIndex bucketsSize_;
643 BucketIndex itemCount_;
659 friend class ValueIteratorBase;
662 enum { itemsPerPage = 8 };
664 typedef unsigned int PageIndex;
666 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 669 IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}
670 ValueInternalArray *array_;
671 Value **currentPageIndex_;
672 unsigned int currentItemIndex_;
674 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 676 ValueInternalArray();
677 ValueInternalArray(
const ValueInternalArray &
other);
679 ~ValueInternalArray();
683 void resize(ArrayIndex newSize);
689 ArrayIndex
size()
const;
694 static bool equals(
const IteratorState &x,
const IteratorState &
other);
695 static void increment(IteratorState &iterator);
696 static void decrement(IteratorState &iterator);
697 static Value &dereference(
const IteratorState &iterator);
698 static Value &unsafeDereference(
const IteratorState &iterator);
699 static int distance(
const IteratorState &x,
const IteratorState &y);
700 static ArrayIndex indexOf(
const IteratorState &iterator);
701 void makeBeginIterator(IteratorState &
it)
const;
702 void makeEndIterator(IteratorState &
it)
const;
703 void makeIterator(IteratorState &
it, ArrayIndex
index)
const;
705 void makeIndexValid(ArrayIndex
index);
709 PageIndex pageCount_;
771 class JSON_API ValueArrayAllocator {
773 virtual ~ValueArrayAllocator();
774 virtual ValueInternalArray *newArray() = 0;
775 virtual ValueInternalArray *newArrayCopy(
const ValueInternalArray &
other) = 0;
776 virtual void destructArray(ValueInternalArray *
array) = 0;
788 virtual void reallocateArrayPageIndex(
Value **&indexes,
789 ValueInternalArray::PageIndex &indexCount,
790 ValueInternalArray::PageIndex minNewIndexCount) = 0;
791 virtual void releaseArrayPageIndex(
Value **indexes, ValueInternalArray::PageIndex indexCount) = 0;
792 virtual Value *allocateArrayPage() = 0;
793 virtual void releaseArrayPage(
Value *
value) = 0;
795 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 807 #ifndef JSON_VALUE_USE_INTERNAL_MAP 843 #ifndef JSON_VALUE_USE_INTERNAL_MAP 849 ValueInternalArray::IteratorState array_;
850 ValueInternalMap::IteratorState map_;
874 #ifndef JSON_VALUE_USE_INTERNAL_MAP 927 #ifndef JSON_VALUE_USE_INTERNAL_MAP 928 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t);
963 #endif // CPPTL_JSON_H_INCLUDED
Experimental do not use: Allocator to customize member name and string value memory management done b...
bool compare(const P &i, const P &j)
Basic3DVector & operator=(const Basic3DVector &)=default
Assignment operator.
a comment placed on the line before a value
Value::ObjectValues::iterator current_
std::vector< const PathArgument * > InArgs
std::vector< std::string > Members
bool operator<(IOVSyncValue const &iLHS, IOVSyncValue const &iRHS)
bool operator==(const SelfType &other) const
virtual char * makeMemberName(const char *memberName) const =0
a comment just after a value on the same line
bool operator!=(const SelfType &other) const
constexpr bool operator<=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
difference_type computeDistance(const SelfType &other) const
bool operator>(DTCELinkId const &lhs, DTCELinkId const &rhs)
Iterator for object and array value.
ValueIteratorBase SelfType
void copy(const SelfType &other)
location
10.6 INPUT and workflows
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
UInt index() const
Return the index of the referenced Value. -1 if it is not an arrayValue.
SelfType & operator=(const ValueIteratorBase &other)
std::vector< PathArgument > Args
void invalidPath(const std::string &path, int location)
void swap(Association< C > &lhs, Association< C > &rhs)
difference_type operator-(const SelfType &other) const
void makePath(const std::string &path, const InArgs &in)
constexpr bool operator>=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
Value key() const
Return either the index or the member name of the referenced value as a Value.
const iterator for object and array value.
ValueConstIterator const_iterator
SelfType & operator=(const SelfType &other)
virtual void releaseStringValue(char *value) const =0
static const UInt maxUInt
bool isEqual(const SelfType &other) const
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
const Value & resolve(const Value &root) const
std::map< CZString, Value > ObjectValues
reco::JetExtendedAssociation::JetExtendedData Value
array value (ordered list)
key
prepare the HTCondor submission files and eventually submit them
ValueConstIterator SelfType
reference operator*() const
StaticString(const char *czstring)
bool operator!=(DTCELinkId const &lhs, DTCELinkId const &rhs)
void addPathInArg(const std::string &path, const InArgs &in, InArgs::const_iterator &itInArg, PathArgument::Kind kind)
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
Experimental and untested: represents a "path" to access a node.
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())
const char * c_str() const
ValueType
Type of the value held by a Value object.
Experimental and untested: represents an element of the "path" to access a node.
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
T operator[](int i) const
virtual char * duplicateStringValue(const char *value, unsigned int length=unknown) const =0
Lightweight wrapper to tag static string.
JSON (JavaScript Object Notation).
virtual void releaseMemberName(char *memberName) const =0
object value (collection of name/value pairs).
a comment on the line after a value (only make sense for root value)
reference operator*() const
const char * memberName() const
Return the member name of the referenced Value. "" if it is not an objectValue.
virtual ~ValueAllocator()
base class for Value iterators.