32 #ifndef _QORE_QORELISTNODE_H 34 #define _QORE_QORELISTNODE_H 36 #include <qore/AbstractQoreNode.h> 53 friend class StackList;
54 friend struct qore_list_private;
67 struct qore_list_private *
priv;
134 DLLEXPORT
QoreListNode(
const QoreTypeInfo* valueTypeInfo);
456 DLLEXPORT
bool empty()
const;
510 #include <qore/ReferenceHolder.h> 544 DLLLOCAL
void *
operator new(size_t);
565 DLLEXPORT
bool next();
574 DLLEXPORT
bool prev();
597 DLLEXPORT
bool first()
const;
600 DLLEXPORT
bool last()
const;
621 return pos == -1 ? false :
true;
669 DLLEXPORT
bool next();
678 DLLEXPORT
bool prev();
695 DLLEXPORT
bool first()
const;
698 DLLEXPORT
bool last()
const;
716 return pos == -1 ? false :
true;
720 DLLEXPORT
void reset();
730 DLLLOCAL
void discard_intern() {
731 if (needs_deref && val)
737 val = exp->
evalList(needs_deref, xsink);
749 DLLLOCAL
void *
operator new(size_t);
784 needs_deref = n_needs_deref;
812 else if (!needs_deref || !val->
is_unique()) {
829 DLLLOCAL
operator bool()
const {
return val != 0; }
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
DLLLOCAL bool valid() const
returns true if the iterator is pointing to a valid element
Definition: QoreListNode.h:715
DLLLOCAL void setNeedsEval()
this function is not exported in the qore library
DLLLOCAL const QoreListNode * operator->() const
returns a pointer to the QoreListNode object being managed
Definition: QoreListNode.h:823
DLLLOCAL qore_size_t index() const
returns the current iterator position in the list or -1 if not pointing at a valid element ...
Definition: QoreListNode.h:606
DLLEXPORT QoreListNode * sortStable() const
returns a new list based on executing mergesort on the source list ("this")
DLLEXPORT bool first() const
returns true when the iterator is pointing to the first element in the list
DLLEXPORT bool last() const
returns true when the iterator is pointing to the last element in the list
DLLEXPORT void pop_entry(qore_size_t index, ExceptionSink *xsink)
DLLEXPORT ConstListIterator(const QoreListNode *lst, qore_size_t n_pos=-1)
initializes the iterator to the position given or, if omitted, just before the first element ...
DLLEXPORT void merge(const QoreListNode *list)
appends the elements of "list" to this list
DLLLOCAL void clearNeedsEval()
this function is not exported in the qore library
DLLEXPORT AbstractQoreNode * max() const
returns the element having the highest value (determined by calling OP_LOG_GT - the greater-than ">" ...
DLLEXPORT bool next()
moves the iterator to the next element, returns true if the iterator is pointing to an element of the...
DLLLOCAL bool isVariableList() const
this function is not exported in the qore library
DLLEXPORT ListIterator(QoreListNode *lst, qore_size_t n_pos=-1)
initializes the iterator to the position given or, if omitted, just before the first element ...
DLLEXPORT const QoreTypeInfo * getValueTypeInfo() const
returns the value type declaration (if set)
virtual DLLLOCAL int64 bigIntEvalImpl(ExceptionSink *xsink) const
always returns 0
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...
DLLLOCAL int mergesort(const ResolvedCallReferenceNode *fr, bool ascending, ExceptionSink *xsink)
mergesort sorts the list in-place (stable)
DLLLOCAL ~QoreListNodeEvalOptionalRefHolder()
clears the object (dereferences the old object if necessary)
Definition: QoreListNode.h:764
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
for initialization of lists in the parse tree at parse time (always returns "this") ...
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:74
DLLEXPORT bool last() const
returns true when the iterator is pointing to the last element in the list
DLLLOCAL bool valid() const
returns true if the iterator is pointing to a valid element
Definition: QoreListNode.h:620
DLLEXPORT bool next()
moves the iterator to the next element, returns true if the iterator is pointing to an element of the...
For use on the stack only: iterates through a the elements of a QoreListNode.
Definition: QoreListNode.h:538
DLLEXPORT QoreListNode * sort() const
returns a new list based on quicksorting the source list ("this")
DLLEXPORT AbstractQoreNode ** getExistingEntryPtr(qore_size_t index)
DLLEXPORT bool empty() const
returns true if the list is empty
DLLEXPORT const AbstractQoreNode * getValue() const
returns a pointer to the value of the list element
DLLEXPORT AbstractQoreNode * retrieve_entry(qore_size_t index)
returns the element at "index" (first element is index 0)
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
DLLEXPORT AbstractQoreNode * get_referenced_entry(qore_size_t index) const
returns the element at "index" (first element is index 0), the caller owns the reference ...
DLLLOCAL bool empty() const
returns true if the list is empty
Definition: QoreListNode.h:615
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when emp...
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
DLLLOCAL void setFinalized()
this function is not exported in the qore library
DLLEXPORT int getEntryAsInt(qore_size_t index) const
returns the value of element at "index" as an integer (first element is index 0)
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...
DLLLOCAL QoreListNode * eval_intern(ExceptionSink *xsink) const
does an unconditional evaluation of the list and returns the new list, 0 if there is a qore-language ...
virtual DLLEXPORT ~QoreListNode()
the destructor is protected so it cannot be called directly
DLLLOCAL void discard()
clears the object (dereferences the old object if necessary)
Definition: QoreListNode.h:769
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns true if the list contains parse expressions and therefore needs evaluation to return a value...
DLLEXPORT bool prev()
moves the iterator to the previous element, returns true if the iterator is pointing to an element of...
DLLEXPORT QoreListNode * copyListFrom(qore_size_t index) const
performs a deep copy of the list starting from element "offset" and returns the new list ...
DLLLOCAL QoreListNode * getList()
returns the list
Definition: QoreListNode.h:612
DLLEXPORT QoreListNode * listRefSelf() const
returns "this" with an incremented reference count
DLLEXPORT bool prev()
moves the iterator to the previous element, returns true if the iterator is pointing to an element of...
DLLEXPORT void push(AbstractQoreNode *val)
adds a value to the list
DLLEXPORT AbstractQoreNode * min() const
returns the element having the lowest value (determined by calling OP_LOG_LT - the less-than "<" oper...
DLLLOCAL void assignEval(const QoreListNode *exp)
assigns a new value by executing the given list and dereference flag to this object, dereferences the old object if necessary
Definition: QoreListNode.h:776
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 AbstractQoreNode ** getValuePtr() const
returns a pointer to a pointer of the value of the list element, so it can be changed externally ...
DLLEXPORT QoreListNode * reverse() const
returns a list with the order of the elements reversed
DLLEXPORT QoreListNode * sortDescending() const
returns a new list based on quicksorting the source list ("this") in descending order ...
DLLLOCAL QoreListNode * parseInitList(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
for initialization of lists in the parse tree at parse time (always returns "this") ...
DLLEXPORT AbstractQoreNode * pop()
returns the last element of the list, the length is decremented by one, caller owns the reference ...
DLLLOCAL bool empty() const
returns true if the list is empty
Definition: QoreListNode.h:710
DLLLOCAL void setVariableList()
this function is not exported in the qore library
DLLEXPORT QoreListNode * sortDescendingStable() const
returns a new list based on executing mergesort on the source list ("this") in descending order ...
DLLLOCAL qore_size_t index() const
returns the current iterator position in the list or -1 if not pointing at a valid element ...
Definition: QoreListNode.h:701
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:47
DLLEXPORT bool first() const
returns true when the iterator is pointing to the first element in the list
DLLEXPORT AbstractQoreNode * getValue() const
returns a pointer to the value of the list element
DLLEXPORT AbstractQoreNode * swapValue(AbstractQoreNode *val) const
swaps the current value with the given value and returns the old value; must be called with reference...
DLLLOCAL const QoreListNode * operator*() const
returns a pointer to the QoreListNode object being managed
Definition: QoreListNode.h:826
virtual DLLEXPORT AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
evaluates the list and returns a value (or 0)
DLLEXPORT QoreListNode * evalList(ExceptionSink *xsink) const
evaluates the list and returns a value (or 0)
DLLEXPORT void deref(ExceptionSink *xsink)
decrements the reference count and calls derefImpl() if there_can_be_only_one is false, otherwise does nothing
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:241
DLLLOCAL qore_size_t max() const
returns the number of elements in the list
Definition: QoreListNode.h:609
DLLEXPORT int delete_entry(qore_size_t index, ExceptionSink *xsink)
DLLEXPORT AbstractQoreNode * takeValue()
returns the current value with the reference count that belongs to the list and sets the list entry t...
intptr_t qore_offset_t
used for offsets that could be negative
Definition: common.h:77
DLLEXPORT void ref() const
increments the reference count
virtual DLLLOCAL bool boolEvalImpl(ExceptionSink *xsink) const
always returns false
DLLEXPORT void splice(qore_offset_t offset, ExceptionSink *xsink)
truncates the list at position "offset" (first element is offset 0)
DLLEXPORT bool is_unique() const
returns true if the reference count is 1
base class for resolved call references
Definition: CallReferenceNode.h:130
virtual DLLLOCAL int integerEvalImpl(ExceptionSink *xsink) const
always returns 0
DLLEXPORT void reset()
resets the iterator to its initial state
DLLEXPORT void set_entry(qore_size_t index, AbstractQoreNode *val, ExceptionSink *xsink)
sets the value of a list element
DLLEXPORT AbstractQoreNode * getReferencedValue() const
returns the current value with an incremented reference count
DLLLOCAL void assign(bool n_needs_deref, QoreListNode *n_val)
assigns a new value and dereference flag to this object, dereferences the old object if necessary ...
Definition: QoreListNode.h:782
DLLEXPORT AbstractQoreNode ** get_entry_ptr(qore_size_t index)
DLLLOCAL bool isFinalized() const
this function is not exported in the qore library
static DLLLOCAL const char * getStaticTypeName()
returns true if the list does not contain any parse expressions, otherwise returns false ...
Definition: QoreListNode.h:186
DLLLOCAL void edit()
will create a unique list so the list can be edited
Definition: QoreListNode.h:807
virtual DLLLOCAL double floatEvalImpl(ExceptionSink *xsink) const
always returns 0.0
DLLLOCAL AbstractQoreNode * eval_entry(qore_size_t num, ExceptionSink *xsink) const
this function is not exported in the qore library
DLLEXPORT const QoreTypeInfo * getTypeInfo() const
returns the type info structure for the current value; also works for lists with a specific value typ...
DLLEXPORT qore_size_t size() const
returns the number of elements in the list
DLLLOCAL const QoreListNode * getList() const
returns the list
Definition: QoreListNode.h:707
For use on the stack only: manages result of the optional evaluation of a QoreListNode.
Definition: QoreListNode.h:724
DLLEXPORT AbstractQoreNode * shift()
returns the first element of the list, all other entries are moved down to fill up the first position...
DLLEXPORT QoreListNode()
create an empty list
DLLEXPORT AbstractQoreNode * getReferencedValue() const
returns the current value with an incremented reference count
a templated class to manage a reference count of an object that can throw a Qore-language exception w...
Definition: ReferenceHolder.h:51
DLLLOCAL QoreListNode * getReferencedValue()
returns a referenced value - the caller will own the reference
Definition: QoreListNode.h:798
DLLEXPORT QoreListNode * extract(qore_offset_t offset, ExceptionSink *xsink)
truncates the list at position "offset" (first element is offset 0) and returns any elements removed ...
For use on the stack only: iterates through elements of a const QoreListNode.
Definition: QoreListNode.h:645
struct qore_list_private * priv
this structure holds the private implementation for the type
Definition: QoreListNode.h:67
virtual DLLEXPORT bool derefImpl(ExceptionSink *xsink)
dereferences all elements of the list
DLLLOCAL bool needsDeref() const
returns true if the object contains a temporary (evaluated) value that needs a dereference ...
Definition: QoreListNode.h:789
DLLLOCAL int qsort(const ResolvedCallReferenceNode *fr, qore_size_t left, qore_size_t right, bool ascending, ExceptionSink *xsink)
qsort sorts the list in-place (unstable)
DLLLOCAL qore_size_t max() const
returns the number of elements in the list
Definition: QoreListNode.h:704
DLLEXPORT QoreListNode * copy() const
performs a deep copy of the list and returns the new list