|
Qore Programming Language
0.9.16
|
32 #ifndef _QORE_QOREHASHNODE_H
34 #define _QORE_QOREHASHNODE_H
36 #include <qore/AbstractQoreNode.h>
56 friend class hash_assignment_priv;
57 friend class qore_object_private;
58 friend class qore_hash_private;
69 class qore_hash_private *
priv;
104 DLLEXPORT
QoreHashNode(
const QoreTypeInfo* valueTypeInfo);
242 DLLEXPORT
bool getKeyAsBool(
const char* key,
bool &found)
const;
249 DLLEXPORT
QoreValue& getKeyValueReference(
const char* key);
339 DLLEXPORT
bool empty()
const;
346 DLLEXPORT
bool existsKey(
const char* key)
const;
398 DLLLOCAL
virtual void parseInit(
QoreValue& val, LocalVar* oflag,
int pflag,
int& lvids,
const QoreTypeInfo*& typeInfo);
401 DLLLOCAL
void clear(
ExceptionSink* xsink,
bool reverse =
false);
413 #include <qore/ReferenceHolder.h>
435 friend class qhi_priv;
448 DLLLOCAL
void*
operator new(size_t);
464 DLLEXPORT
bool next();
470 DLLEXPORT
bool prev();
473 DLLEXPORT
const char*
getKey()
const;
501 DLLEXPORT
bool first()
const;
504 DLLEXPORT
bool last()
const;
507 DLLEXPORT
bool empty()
const;
510 DLLEXPORT
bool valid()
const;
538 DLLEXPORT
bool next();
544 DLLEXPORT
bool prev();
547 DLLEXPORT
bool first()
const;
550 DLLEXPORT
bool last()
const;
588 DLLEXPORT
bool next();
594 DLLEXPORT
bool prev();
597 DLLEXPORT
const char*
getKey()
const;
615 DLLEXPORT
bool first()
const;
618 DLLEXPORT
bool last()
const;
621 DLLEXPORT
bool empty()
const;
624 DLLEXPORT
bool valid()
const;
627 DLLEXPORT
void reset();
655 DLLEXPORT
bool next();
661 DLLEXPORT
bool prev();
664 DLLEXPORT
bool first()
const;
667 DLLEXPORT
bool last()
const;
672 friend class hash_assignment_priv;
722 DLLEXPORT
void reassign(
const char* key,
bool must_already_exist =
false);
730 DLLEXPORT
void reassign(
const std::string& key,
bool must_already_exist =
false);
735 DLLEXPORT
operator bool()
const;
764 class hash_assignment_priv *
priv;
769 DLLLOCAL
void*
operator new(size_t) =
delete;
772 #endif // _QORE_HASH_H
const DLLEXPORT QoreTypeInfo * getTypeInfo() const
returns the type info for the current value
DLLEXPORT QoreValue getReferenced() const
returns the value of the current key with an incremented reference count
virtual DLLLOCAL QoreValue evalImpl(bool &needs_deref, ExceptionSink *xsink) const
optionally evaluates the argument
DLLLOCAL void setNeedsEval()
sets "needs_eval" to true and "value" to false
DLLEXPORT bool prev()
moves to the previous element, returns false when there are no more elements to iterate
const DLLEXPORT TypedHashDecl * getHashDecl() const
returns the hash's type declaration, if any
DLLLOCAL ConstHashIterator & operator=(const HashIterator &)
this function is not implemented; it is here as a protected function in order to prohibit it from bei...
DLLEXPORT bool empty() const
returns true if the hash is empty
const DLLEXPORT char * getFirstKey() const
returns the cstring value of the first key in the hash
const DLLEXPORT QoreTypeInfo * getTypeInfo() const
returns the type info for the current value
virtual DLLEXPORT int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const
concatenate the verbose string representation of the list (including all contained values) to an exis...
DLLEXPORT int setKeyValue(const char *key, QoreValue value, ExceptionSink *xsink)
sets the value of "key" to "value"
bool value
this is true for values, if false then either the type needs evaluation to produce a value or is a pa...
Definition: AbstractQoreNode.h:324
DLLEXPORT QoreValue getKeyValue(const char *key, ExceptionSink *xsink) const
returns the value of the given key
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
reverse constant iterator class for QoreHashNode, to be only created on the stack
Definition: QoreHashNode.h:640
DLLEXPORT bool existsKeyValue(const char *key) const
returns true if the hash contains the given key and the key has a value (i.e. is not NOTHING)
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
DLLEXPORT QoreValue getKeyValueExistence(const char *key, bool &exists, ExceptionSink *xsink) const
returns the value of the given key
DLLLOCAL void clearNeedsEval()
sets "needs_eval" to false and "value" to true
DLLEXPORT bool last() const
returns true if on the first key of the hash
DLLEXPORT QoreHashNode * getHash() const
returns the hash
const DLLEXPORT QoreHashNode * getHash() const
returns the hash
DLLEXPORT QoreValue get() const
returns the value of the current key
const DLLEXPORT char * getKey() const
returns the current key
DLLEXPORT QoreHashNode * copy() const
performs a copy of the hash and returns the new hash
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:73
DLLEXPORT ~ConstHashIterator()
Destroys the iterator.
DLLEXPORT bool compareSoft(const QoreHashNode *h, ExceptionSink *xsink) const
does a deep "soft" compare of all hash elements (types may be converted for the comparison) and retur...
DLLEXPORT bool getKeyAsBool(const char *key, bool &found) const
returns the value of the key as a bool
DLLEXPORT ~HashAssignmentHelper()
destroys the object and does post processing on the new value
DLLEXPORT void deleteKey(const QoreString *key, ExceptionSink *xsink)
performs a delete operation on the value of the given key
DLLEXPORT ~ReverseConstHashIterator()
Destroys the iterator.
DLLEXPORT HashAssignmentHelper(QoreHashNode &n_h, const char *key, bool must_already_exist=false)
constructor taking a const char*
DLLEXPORT bool first() const
returns true if on the first key of the hash
DLLEXPORT QoreValue swap(QoreValue v, ExceptionSink *xsink)
swaps the current value with the new value of the hash key, assumes that the new value is already ref...
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
DLLEXPORT bool next()
moves to the next element, returns false when there are no more elements to iterate
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality ("deep compare" including all contained values) without type conversions (hard com...
DLLEXPORT bool prev()
moves to the previous element, returns false when there are no more elements to iterate
constant iterator class for QoreHashNode, to be only created on the stack
Definition: QoreHashNode.h:563
const DLLEXPORT QoreValue get() const
returns the value of the current key
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
DLLEXPORT bool next()
moves to the next element in reverse order, returns false when there are no more elements to iterate
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreHashNode.h:391
DLLEXPORT void removeKey(const QoreString *key, ExceptionSink *xsink)
removes the given key from the hash and derefences its value, if any
DLLEXPORT QoreListNode * getValues() const
returns a QoreListNode of AbstractQoreNode pointers representing all values in the hash; caller owns ...
iterator class for QoreHashNode, to be only created on the stack
Definition: QoreHashNode.h:433
DLLEXPORT QoreHashNode * hashRefSelf() const
returns "this" with an incremented reference count
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
DLLEXPORT bool prev()
moves to the previous element in reverse order, returns false when there are no more elements to iter...
DLLEXPORT bool valid() const
returns true if the iterator is currently pointing at a valid element
virtual DLLEXPORT bool derefImpl(ExceptionSink *xsink)
dereferences all elements of the hash
DLLLOCAL HashIterator & operator=(const HashIterator &)
this function is not implemented; it is here as a private function in order to prohibit it from being...
DLLEXPORT QoreValue getReferenced() const
returns the value of the current key with an incremented reference count
DLLEXPORT qore_size_t size() const
returns the number of members in the hash, executes in constant time
DLLEXPORT bool first() const
returns true if on the last key of the hash
DLLEXPORT ~HashIterator()
Destroys the iterator.
DLLEXPORT ReverseConstHashIterator(const QoreHashNode *h)
initializes the iterator with the passed hash
DLLEXPORT QoreValue get() const
returns the current value of the hash key; the pointer returned is still owned by the hash
DLLEXPORT void deleteKey(ExceptionSink *xsink)
deletes the key from the hash and dereferences the value
const DLLEXPORT QoreTypeInfo * getValueTypeInfo() const
returns the value type declaration (only possible if there is no hashdecl set)
DLLEXPORT void assign(QoreValue v, ExceptionSink *xsink)
assigns a value to the hash key, dereferences any old value, assumes that the value is already refere...
typed hash declaration
Definition: TypedHashDecl.h:44
virtual const DLLEXPORT char * getTypeName() const
returns the type name as a c string
DLLEXPORT bool first() const
returns true if on the first key of the hash
DLLEXPORT QoreHashNode()
creates an empty hash
DLLEXPORT bool existsKey(const char *key) const
returns true if the hash contains the given key
DLLEXPORT bool last() const
returns true if on the last key of the hash
DLLEXPORT ~ReverseHashIterator()
Destroys the iterator.
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
DLLEXPORT QoreListNode * getKeys() const
returns a QoreListNode of QoreStringNode pointers representing all keys in the hash,...
use this class to make assignments to hash keys from a pointer to the key value
Definition: QoreHashNode.h:671
class qore_hash_private * priv
private implementation of the class
Definition: QoreHashNode.h:69
static const DLLLOCAL char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreHashNode.h:386
reverse iterator class for QoreHashNode, to be only created on the stack
Definition: QoreHashNode.h:523
virtual DLLEXPORT ~QoreHashNode()
deletes the object, cannot be called directly (use deref(ExceptionSink*) instead)
virtual DLLEXPORT AbstractQoreNode * realCopy() const
performs a copy of the hash and returns the new hash
DLLEXPORT QoreValue takeKeyValue(const char *key)
removes the value from the hash and returns the value removed, if any
DLLEXPORT bool next()
moves to the next element in reverse order, returns false when there are no more elements to iterate
virtual DLLLOCAL void parseInit(QoreValue &val, LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
initializes during parsing
DLLEXPORT bool last() const
returns true if on the first key of the hash
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when emp...
DLLEXPORT bool first() const
returns true if on the last key of the hash
DLLLOCAL HashIterator(const HashIterator &)
this function is not implemented; it is here as a private function in order to prohibit it from being...
DLLEXPORT int64 getKeyAsBigInt(const char *key, bool &found) const
returns the value of the key as an int64
const DLLEXPORT QoreTypeInfo * getTypeInfo() const
returns the type info structure for the current value; also works for hashes derived from a TypedHash...
DLLEXPORT bool valid() const
returns true if the iterator is currently pointing at a valid element
DLLEXPORT QoreString * getKeyString() const
returns a QoreString for the current key, the caller owns QoreString returned
DLLEXPORT ReverseHashIterator(QoreHashNode *h)
initializes the iterator with the passed hash
const DLLEXPORT char * getKey() const
returns the current key
DLLEXPORT QoreValue removeKeyValue()
removes the key value and returns the value returned
DLLEXPORT bool last() const
returns true if on the last key of the hash
DLLEXPORT bool empty() const
returns true if the hash has no members, false if not
DLLEXPORT void reset()
resets the iterator to its initial state
const qore_type_t NT_HASH
type value for QoreHashNode
Definition: node_types.h:51
DLLEXPORT ConstHashIterator(const QoreHashNode *h)
initializes the iterator with the passed hash
DLLEXPORT void reassign(const char *key, bool must_already_exist=false)
reassigns the object to the given key for a new assignment
const DLLEXPORT char * getLastKey() const
returns the cstring value of the last key in the hash
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
DLLEXPORT QoreValue operator*() const
returns the current value of the hash key; any pointer returned is still owned by the hash
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
DLLEXPORT void merge(const QoreHashNode *h, ExceptionSink *xsink)
appends all key-value pairs of "h" to this hash
DLLEXPORT QoreString * getKeyString() const
returns a QoreString for the current key, the caller owns QoreString returned
DLLEXPORT bool empty() const
returns true if the hash is empty
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality ("deep compare" including all contained values) with possible type conversion (sof...
DLLEXPORT bool compareHard(const QoreHashNode *h, ExceptionSink *xsink) const
does a deep "hard" compare of all hash elements (no type conversions are performed) and returns true ...
class hash_assignment_priv * priv
private implementation
Definition: QoreHashNode.h:764
DLLEXPORT bool next()
moves to the next element, returns false when there are no more elements to iterate
DLLEXPORT bool prev()
moves to the previous element in reverse order, returns false when there are no more elements to iter...