32 #ifndef _QORE_QOREVALUE_H 33 #define _QORE_QOREVALUE_H 37 typedef unsigned char valtype_t;
43 #define QV_Bool (valtype_t)0 44 #define QV_Int (valtype_t)1 45 #define QV_Float (valtype_t)2 46 #define QV_Node (valtype_t)3 47 #define QV_Ref (valtype_t)4 65 template<
typename Type>
67 typedef Type * Result;
70 static Result cast(QV *qv, valtype_t type) {
72 assert(!qv->v.n || dynamic_cast<Result>(qv->v.n));
73 return reinterpret_cast<Result
>(qv->v.n);
83 static bool cast(QV *qv, valtype_t type) {
84 return qv->getAsBool();
91 typedef double Result;
94 static double cast(QV *qv, valtype_t type) {
95 return qv->getAsFloat();
102 typedef int64 Result;
104 template<
typename QV>
105 static int64 cast(QV *qv, valtype_t type) {
106 return qv->getAsBigInt();
173 DLLEXPORT
bool getAsBool()
const;
176 DLLEXPORT
int64 getAsBigInt()
const;
179 DLLEXPORT
double getAsFloat()
const;
182 DLLEXPORT
void ref()
const;
234 DLLEXPORT
bool isEqualHard(
const QoreValue v)
const;
237 DLLEXPORT
void sanitize();
246 DLLEXPORT
void clear();
260 assert(dynamic_cast<T*>(v.
n));
261 T* rv =
reinterpret_cast<T*
>(v.
n);
270 DLLLOCAL
typename detail::QoreValueCastHelper<T>::Result
get() {
278 DLLLOCAL
typename detail::QoreValueCastHelper<const T>::Result
get()
const {
294 DLLEXPORT
const QoreTypeInfo* getTypeInfo()
const;
300 DLLEXPORT
const char* getTypeName()
const;
303 DLLEXPORT
const char* getFullTypeName()
const;
306 DLLEXPORT
bool hasNode()
const;
309 DLLEXPORT
bool isNothing()
const;
312 DLLEXPORT
bool isNull()
const;
315 DLLEXPORT
bool isNullOrNothing()
const;
370 DLLLOCAL
operator bool()
const {
371 return v.type ==
QV_Node && v.v.n;
397 DLLLOCAL
bool isTemp()
const {
return needs_deref; }
400 DLLLOCAL
void clearTemp() {
406 DLLLOCAL
operator bool()
const {
407 return v.type ==
QV_Node && v.v.n;
423 if (needs_deref != temp)
431 DLLEXPORT
void ensureReferencedValue();
435 DLLLOCAL T* takeReferencedNode() {
452 return v.takeNodeIntern();
476 DLLEXPORT
QoreValue takeReferencedValue();
480 DLLEXPORT
void sanitize();
DLLEXPORT AbstractQoreNode * takeNodeIntern()
returns the internal AbstractQoreNode pointer, does not check that type == QV_Node, leaves the object empty
double f
for double values
Definition: QoreValue.h:58
base class for holding a QoreValue object
Definition: QoreValue.h:319
this is the union that stores values in QoreValue
Definition: QoreValue.h:55
qore_value_u v
the actual value is stored here
Definition: QoreValue.h:123
allows storing a value and setting a boolean flag that indicates if the value should be dereference i...
Definition: QoreValue.h:376
evaluates an AbstractQoreNode and dereferences the stored value in the destructor ...
Definition: QoreValue.h:484
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
static void discard(AbstractQoreNode *n, ExceptionSink *xsink)
to deref an AbstractQoreNode (when the pointer may be 0)
Definition: QoreLib.h:327
bool needs_deref
flag indicating if the value should be dereferenced in the destructor or not
Definition: QoreValue.h:383
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
ExceptionSink * xsink
for possible Qore-language exceptions
Definition: QoreValue.h:324
used in QoreValue::get()
Definition: QoreValue.h:66
#define QV_Node
for heap-allocated values
Definition: QoreValue.h:46
namespace for implementation details of QoreValue functions
Definition: QoreValue.h:63
valtype_t type
indicates the value that the union is holding
Definition: QoreValue.h:125
DLLLOCAL QoreValue takeValue(bool &nd)
returns the stored value and sets the dereference flag as an output variable
Definition: QoreValue.h:459
QoreValue v
the vlaue held
Definition: QoreValue.h:322
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:112
AbstractQoreNode * n
for all heap-allocated values
Definition: QoreValue.h:59
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:47
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
int64 i
for integer values
Definition: QoreValue.h:57
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:71
bool b
for boolean values
Definition: QoreValue.h:56
holds an object and dereferences it in the destructor
Definition: QoreValue.h:343
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values ...