32 #ifndef _QORE_ABSTRACTQORENODE_H
34 #define _QORE_ABSTRACTQORENODE_H
37 #include <qore/QoreReferenceCounter.h>
44 #define FMT_YAML_SHORT -2
64 DLLLOCAL
virtual bool getAsBoolImpl()
const {
return false; }
70 DLLLOCAL
virtual int getAsIntImpl()
const {
return 0; }
76 DLLLOCAL
virtual int64 getAsBigIntImpl()
const {
return 0; }
82 DLLLOCAL
virtual double getAsFloatImpl()
const {
return 0.0; }
115 DLLEXPORT
virtual int integerEvalImpl(
ExceptionSink* xsink)
const;
122 DLLEXPORT
virtual bool boolEvalImpl(
ExceptionSink* xsink)
const;
129 DLLEXPORT
virtual double floatEvalImpl(
ExceptionSink* xsink)
const;
144 DLLEXPORT
virtual void customRef()
const;
189 DLLEXPORT
AbstractQoreNode(
qore_type_t t,
bool n_value,
bool n_needs_eval,
bool n_there_can_be_only_one =
false,
bool n_custom_reference_handlers =
false);
305 DLLEXPORT
virtual const char*
getTypeName()
const = 0;
384 DLLEXPORT
void ref()
const;
404 DLLEXPORT QoreValue evalValue(
bool& needs_deref,
ExceptionSink* xsink)
const;
431 DLLEXPORT
void deref();
485 DLLLOCAL
void *
operator new(size_t);
DLLEXPORT AbstractQoreNode * refSelf() const
returns "this" with an incremented reference count
virtual DLLEXPORT const char * getTypeName() const =0
returns the type name as a c string
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const =0
tests for equality ("deep compare" including all contained values for container types) with possible ...
virtual DLLEXPORT AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
for use by parse types to initialize them for execution during stage 1 parsing
DLLEXPORT bool getAsBool() const
returns the boolean value of the object
DLLEXPORT AbstractQoreNode * eval(ExceptionSink *xsink) const
evaluates the object and returns a value (or 0)
DLLEXPORT double getAsFloat() const
returns the float value of the object
virtual DLLEXPORT int64 bigIntEvalImpl(ExceptionSink *xsink) const
should never be called for value types
DLLEXPORT int64 bigIntEval(ExceptionSink *xsink) const
evaluates the object and returns a 64-bit integer value
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
DLLLOCAL UniqueValueQoreNode(qore_type_t t)
constructor takes the type argument
Definition: AbstractQoreNode.h:491
DLLEXPORT int integerEval(ExceptionSink *xsink) const
evaluates the object and returns an integer value
DLLLOCAL SimpleQoreNode(const SimpleQoreNode &v)
copy constructor
Definition: AbstractQoreNode.h:424
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns the value of the type converted to a string, default implementation: returns the empty string...
DLLLOCAL UniqueValueQoreNode(const UniqueValueQoreNode &)
copy constructor
Definition: AbstractQoreNode.h:494
virtual DLLEXPORT class DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this type (default implementation: returns ZeroDate...
DLLEXPORT bool boolEval(ExceptionSink *xsink) const
evaluates the object and returns a boolean value
DLLEXPORT int getAsInt() const
returns the integer value of the object
virtual DLLEXPORT AbstractQoreNode * realCopy() const =0
returns a copy of the object; the caller owns the reference count
DLLEXPORT int64 getAsBigInt() const
returns the 64-bit integer value of the object
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
virtual DLLEXPORT AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
should never be called for value types
bool custom_reference_handlers
set to one for objects that need custom reference handlers
Definition: AbstractQoreNode.h:169
bool needs_eval_flag
if this is true then the type can be evaluated
Definition: AbstractQoreNode.h:163
virtual DLLEXPORT double floatEvalImpl(ExceptionSink *xsink) const
should never be called for value types
this class is for value types that will exists only once in the Qore library, reference counting is d...
Definition: AbstractQoreNode.h:479
provides atomic reference counting to Qore objects
Definition: QoreReferenceCounter.h:42
virtual DLLEXPORT int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const =0
concatenate the verbose string representation of the value (including all contained values for contai...
DLLLOCAL bool is_value() const
returns true if the node represents a value
Definition: AbstractQoreNode.h:366
virtual DLLEXPORT int integerEvalImpl(ExceptionSink *xsink) const
should never be called for value types
DLLEXPORT void ref() const
increments the reference count
The base class for all types in Qore expression trees that cannot throw an exception when deleted...
Definition: AbstractQoreNode.h:414
virtual DLLEXPORT bool boolEvalImpl(ExceptionSink *xsink) const
should never be called for value types
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
DLLLOCAL bool needs_eval() const
returns true if the object needs evaluation to return a value, false if not
Definition: AbstractQoreNode.h:267
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const =0
tests for equality ("deep compare" including all contained values for container types) without type c...
bool has_value_api
set to flag with new QoreValue API (derived from ParseNode) - FIXME: to be removed when new ABI is im...
Definition: AbstractQoreNode.h:172
DLLLOCAL bool hasValueApi() const
returns the "has value api" flags - FIXME: remove with new ABI
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:228
DLLLOCAL SimpleValueQoreNode(qore_type_t t, bool n_there_can_be_only_one=false)
creates the object by assigning the type code and setting the "value" flag, unsetting the "needs_eval...
Definition: AbstractQoreNode.h:471
DLLEXPORT AbstractQoreNode(qore_type_t t, bool n_value, bool n_needs_eval, bool n_there_can_be_only_one=false, bool n_custom_reference_handlers=false)
constructor takes the type
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:297
bool there_can_be_only_one
if this is set to true, then reference counting is turned off for objects of this class ...
Definition: AbstractQoreNode.h:166
DLLLOCAL SimpleQoreNode(qore_type_t t, bool n_value, bool n_needs_eval, bool n_there_can_be_only_one=false)
constructor takes the type and value arguments
Definition: AbstractQoreNode.h:421
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:68
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:160
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns itself; objects of this type are not reference-counted and only deleted manually (by static d...
virtual DLLEXPORT ~AbstractQoreNode()
default destructor does nothing
base class for simple value types
Definition: AbstractQoreNode.h:435
DLLLOCAL bool isReferenceCounted() const
returns true if the object is reference-counted
Definition: AbstractQoreNode.h:387
DLLEXPORT double floatEval(ExceptionSink *xsink) const
evaluates the object and returns a floating-point value
qore_type_t type
the type of the object
Definition: AbstractQoreNode.h:157