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> 64 operator const char *()
const {
return str_; }
66 const char *
c_str()
const {
return str_; }
101 #ifdef JSON_VALUE_USE_INTERNAL_MAP 102 friend class ValueInternalLink;
103 friend class ValueInternalMap;
119 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 120 #ifndef JSON_VALUE_USE_INTERNAL_MAP 125 CZString(
const char *cstr, DuplicationPolicy allocate);
132 const char *c_str()
const;
133 bool isStaticString()
const;
142 #ifndef JSON_USE_CPPTL_SMALLMAP 146 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 147 #endif // ifndef JSON_VALUE_USE_INTERNAL_MAP 148 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 171 Value(
const char *beginValue,
const char *endValue);
184 #ifdef JSON_USE_CPPTL 209 const char *asCString()
const;
211 #ifdef JSON_USE_CPPTL 212 CppTL::ConstString asConstString()
const;
216 double asDouble()
const;
223 bool isIntegral()
const;
224 bool isDouble()
const;
225 bool isNumeric()
const;
226 bool isString()
const;
227 bool isArray()
const;
228 bool isObject()
const;
240 bool operator!()
const;
252 void resize(
UInt size);
294 #ifdef JSON_USE_CPPTL 304 #ifdef JSON_USE_CPPTL 308 Value removeMember(
const char *
key);
319 bool isMember(
const char *
key)
const;
322 #ifdef JSON_USE_CPPTL 323 bool isMember(
const CppTL::ConstString &
key)
const;
332 Members getMemberNames()
const;
356 Value &resolveReference(
const char *
key,
bool isStatic);
358 #ifdef JSON_VALUE_USE_INTERNAL_MAP 359 inline bool isItemAvailable()
const {
return itemIsUsed_ == 0; }
361 inline void setItemUsed(
bool isUsed =
true) { itemIsUsed_ = isUsed ? 1 : 0; }
363 inline bool isMemberNameStatic()
const {
return memberNameIsStatic_ == 0; }
365 inline void setMemberNameIsStatic(
bool isStatic) { memberNameIsStatic_ = isStatic ? 1 : 0; }
366 #endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP 373 void setComment(
const char *
text);
393 #ifdef JSON_VALUE_USE_INTERNAL_MAP 394 ValueInternalArray *array_;
395 ValueInternalMap *map_;
402 #ifdef JSON_VALUE_USE_INTERNAL_MAP 403 unsigned int itemIsUsed_ : 1;
404 int memberNameIsStatic_ : 1;
453 typedef std::vector<const PathArgument *>
InArgs;
454 typedef std::vector<PathArgument>
Args;
459 InArgs::const_iterator &itInArg,
485 #ifdef JSON_VALUE_USE_INTERNAL_MAP 532 virtual ~ValueMapAllocator();
533 virtual ValueInternalMap *newMap() = 0;
534 virtual ValueInternalMap *newMapCopy(
const ValueInternalMap &
other) = 0;
535 virtual void destructMap(ValueInternalMap *
map) = 0;
536 virtual ValueInternalLink *allocateMapBuckets(
unsigned int size) = 0;
537 virtual void releaseMapBuckets(ValueInternalLink *
links) = 0;
538 virtual ValueInternalLink *allocateMapLink() = 0;
539 virtual void releaseMapLink(ValueInternalLink *link) = 0;
547 enum { itemPerLink = 6 };
548 enum InternalFlags { flagAvailable = 0, flagUsed = 1 };
552 ~ValueInternalLink();
554 Value items_[itemPerLink];
555 char *keys_[itemPerLink];
556 ValueInternalLink *previous_;
557 ValueInternalLink *next_;
573 friend class ValueIteratorBase;
577 typedef unsigned int HashKey;
578 typedef unsigned int BucketIndex;
580 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 581 struct IteratorState {
582 IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}
583 ValueInternalMap *map_;
584 ValueInternalLink *link_;
585 BucketIndex itemIndex_;
586 BucketIndex bucketIndex_;
588 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 591 ValueInternalMap(
const ValueInternalMap &
other);
597 BucketIndex
size()
const;
601 bool reserveDelta(BucketIndex growth);
603 bool reserve(BucketIndex newItemCount);
609 Value &resolveReference(
const char *
key,
bool isStatic);
611 void remove(
const char *
key);
613 void doActualRemove(ValueInternalLink *link, BucketIndex
index, BucketIndex bucketIndex);
615 ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);
617 Value &setNewItem(
const char *
key,
bool isStatic, ValueInternalLink *link, BucketIndex
index);
619 Value &unsafeAdd(
const char *
key,
bool isStatic, HashKey hashedKey);
621 HashKey
hash(
const char *
key)
const;
626 void makeBeginIterator(IteratorState &
it)
const;
627 void makeEndIterator(IteratorState &
it)
const;
628 static bool equals(
const IteratorState &x,
const IteratorState &
other);
629 static void increment(IteratorState &iterator);
630 static void incrementBucket(IteratorState &iterator);
631 static void decrement(IteratorState &iterator);
632 static const char *
key(
const IteratorState &iterator);
633 static const char *
key(
const IteratorState &iterator,
bool &isStatic);
634 static Value &
value(
const IteratorState &iterator);
635 static int distance(
const IteratorState &x,
const IteratorState &y);
638 ValueInternalLink *buckets_;
639 ValueInternalLink *tailLink_;
640 BucketIndex bucketsSize_;
641 BucketIndex itemCount_;
657 friend class ValueIteratorBase;
660 enum { itemsPerPage = 8 };
662 typedef unsigned int PageIndex;
664 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 667 IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}
668 ValueInternalArray *array_;
669 Value **currentPageIndex_;
670 unsigned int currentItemIndex_;
672 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 674 ValueInternalArray();
675 ValueInternalArray(
const ValueInternalArray &
other);
677 ~ValueInternalArray();
681 void resize(ArrayIndex newSize);
687 ArrayIndex
size()
const;
692 static bool equals(
const IteratorState &x,
const IteratorState &
other);
693 static void increment(IteratorState &iterator);
694 static void decrement(IteratorState &iterator);
695 static Value &dereference(
const IteratorState &iterator);
696 static Value &unsafeDereference(
const IteratorState &iterator);
697 static int distance(
const IteratorState &x,
const IteratorState &y);
698 static ArrayIndex indexOf(
const IteratorState &iterator);
699 void makeBeginIterator(IteratorState &
it)
const;
700 void makeEndIterator(IteratorState &
it)
const;
701 void makeIterator(IteratorState &
it, ArrayIndex
index)
const;
703 void makeIndexValid(ArrayIndex
index);
707 PageIndex pageCount_;
769 class JSON_API ValueArrayAllocator {
771 virtual ~ValueArrayAllocator();
772 virtual ValueInternalArray *newArray() = 0;
773 virtual ValueInternalArray *newArrayCopy(
const ValueInternalArray &
other) = 0;
774 virtual void destructArray(ValueInternalArray *
array) = 0;
786 virtual void reallocateArrayPageIndex(
Value **&indexes,
787 ValueInternalArray::PageIndex &indexCount,
788 ValueInternalArray::PageIndex minNewIndexCount) = 0;
789 virtual void releaseArrayPageIndex(
Value **indexes, ValueInternalArray::PageIndex indexCount) = 0;
790 virtual Value *allocateArrayPage() = 0;
791 virtual void releaseArrayPage(
Value *
value) = 0;
793 #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 805 #ifndef JSON_VALUE_USE_INTERNAL_MAP 841 #ifndef JSON_VALUE_USE_INTERNAL_MAP 847 ValueInternalArray::IteratorState array_;
848 ValueInternalMap::IteratorState map_;
872 #ifndef JSON_VALUE_USE_INTERNAL_MAP 925 #ifndef JSON_VALUE_USE_INTERNAL_MAP 926 explicit ValueIterator(
const Value::ObjectValues::iterator ¤t);
961 #endif // CPPTL_JSON_H_INCLUDED
bool operator==(const SelfType &other) const
bool compare(const P &i, const P &j)
difference_type operator-(const SelfType &other) const
std::vector< std::string > Members
Basic3DVector & operator=(const Basic3DVector &)=default
Assignment operator.
virtual char * makeMemberName(const char *memberName) const =0
bool isEqual(const SelfType &other) const
bool operator<(IOVSyncValue const &iLHS, IOVSyncValue const &iRHS)
const char * c_str() const
virtual void releaseStringValue(char *value) const =0
void addPathInArg(const std::string &path, const InArgs &in, InArgs::const_iterator &itInArg, PathArgument::Kind kind)
Value key() const
Return either the index or the member name of the referenced value as a Value.
Experimental and untested: represents an element of the "path" to access a node.
void makePath(const std::string &path, const InArgs &in)
std::vector< const PathArgument * > InArgs
constexpr bool operator<=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
Lightweight wrapper to tag static string.
ValueConstIterator const_iterator
bool operator>(DTCELinkId const &lhs, DTCELinkId const &rhs)
virtual void releaseMemberName(char *memberName) const =0
static const UInt maxUInt
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
a comment placed on the line before a value
virtual ~ValueAllocator()
SelfType & operator=(const SelfType &other)
void swap(Association< C > &lhs, Association< C > &rhs)
constexpr bool operator>=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
difference_type computeDistance(const SelfType &other) const
reference operator*() const
std::map< CZString, Value > ObjectValues
ValueConstIterator SelfType
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
object value (collection of name/value pairs).
reco::JetExtendedAssociation::JetExtendedData Value
key
prepare the HTCondor submission files and eventually submit them
ValueType
Type of the value held by a Value object.
const char * memberName() const
Return the member name of the referenced Value. "" if it is not an objectValue.
bool operator!=(const SelfType &other) const
void invalidPath(const std::string &path, int location)
virtual char * duplicateStringValue(const char *value, unsigned int length=unknown) const =0
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
a comment just after a value on the same line
base class for Value iterators.
const Value & resolve(const Value &root) const
bool operator!=(DTCELinkId const &lhs, DTCELinkId const &rhs)
UInt index() const
Return the index of the referenced Value. -1 if it is not an arrayValue.
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())
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)
void copy(const SelfType &other)
StaticString(const char *czstring)
SelfType & operator=(const ValueIteratorBase &other)
std::vector< PathArgument > Args
Experimental do not use: Allocator to customize member name and string value memory management done b...
Iterator for object and array value.
T operator[](int i) const
Experimental and untested: represents a "path" to access a node.
const iterator for object and array value.
Value::ObjectValues::iterator current_
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
reference operator*() const
array value (ordered list)