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      66     template<
typename Type>
    68         typedef Type * Result;
    71         static Result cast(QV *qv, valtype_t type) {
    73             assert(!qv->v.n || dynamic_cast<Result>(qv->v.n));
    74             return reinterpret_cast<Result
>(qv->v.n);
    84         static bool cast(QV *qv, valtype_t type) {
    85             return qv->getAsBool();
    92         typedef double Result;
    95         static double cast(QV *qv, valtype_t type) {
    96             return qv->getAsFloat();
   103         typedef int64 Result;
   105         template<
typename QV>
   106         static int64 cast(QV *qv, valtype_t type) {
   107             return qv->getAsBigInt();
   112 class QoreSimpleValue {
   120     DLLLOCAL 
void set(
int64 i) {
   126     DLLLOCAL 
void set(
double f) {
   132     DLLLOCAL 
void set(
bool b) {
   138     DLLEXPORT 
void set(QoreSimpleValue val);
   144     DLLLOCAL QoreSimpleValue& assign(QoreSimpleValue& val) {
   150     DLLLOCAL QoreSimpleValue& assign(
int64 i) {
   156     DLLLOCAL QoreSimpleValue& assign(
double f) {
   162     DLLLOCAL QoreSimpleValue& assign(
bool b) {
   177     DLLEXPORT 
const char* getTypeName() 
const;
   191     DLLEXPORT 
void clear();
   202         assert(dynamic_cast<T*>(v.
n));
   203         T* rv = 
reinterpret_cast<T*
>(v.
n);
   213     DLLLOCAL 
typename detail::QoreValueCastHelper<T>::Result 
get() {
   222     DLLLOCAL 
typename detail::QoreValueCastHelper<const T>::Result 
get() 
const {
   227     DLLEXPORT 
bool getAsBool() 
const;
   230     DLLEXPORT 
int64 getAsBigInt() 
const;
   233     DLLEXPORT 
double getAsFloat() 
const;
   236     DLLEXPORT 
bool hasEffect() 
const;
   239     DLLEXPORT 
bool isNothing() 
const;
   242     DLLEXPORT 
bool isNull() 
const;
   245     DLLEXPORT 
bool isNullOrNothing() 
const;
   248     DLLEXPORT 
bool isValue() 
const;
   251     DLLEXPORT 
bool needsEval() 
const;
   254     DLLEXPORT 
operator bool() 
const;
   272     DLLEXPORT QoreValue(
bool b);
   275     DLLEXPORT QoreValue(
int i);
   278     DLLEXPORT QoreValue(
unsigned int i);
   281     DLLEXPORT QoreValue(
long i);
   284     DLLEXPORT QoreValue(
unsigned long i);
   287     DLLEXPORT QoreValue(
unsigned long long i);
   290     DLLEXPORT QoreValue(
int64 i);
   293     DLLEXPORT QoreValue(
double f);
   308     DLLEXPORT QoreValue(
const QoreSimpleValue& v);
   311     DLLEXPORT QoreValue(
const QoreValue& old);
   314     DLLEXPORT 
void swap(QoreValue& val);
   317     DLLEXPORT 
void ref() 
const;
   320     DLLEXPORT QoreValue refSelf() 
const;
   360     DLLEXPORT 
bool isEqualSoft(
const QoreValue v, 
ExceptionSink* xsink) 
const;
   363     DLLEXPORT 
bool isEqualHard(
const QoreValue v) 
const;
   366     DLLEXPORT 
bool isEqualValue(
const QoreValue v);
   369     DLLEXPORT 
void sanitize();
   372     DLLEXPORT QoreValue& operator=(
const QoreValue& n);
   375     DLLEXPORT QoreValue& operator=(
const QoreSimpleValue& n);
   390     DLLEXPORT QoreValue eval(
bool& needs_deref, 
ExceptionSink* xsink) 
const;
   401     DLLEXPORT 
const QoreTypeInfo* getTypeInfo() 
const;
   406     DLLEXPORT 
const QoreTypeInfo* getFullTypeInfo() 
const;
   409     DLLEXPORT 
const char* getFullTypeName() 
const;
   412     DLLEXPORT 
bool hasNode() 
const;
   415     DLLEXPORT 
bool isReferenceCounted() 
const;
   418     DLLEXPORT 
bool derefCanThrowException() 
const;
   442     DLLLOCAL 
const QoreValue* operator->()
 const { 
return &v; }
   448     DLLLOCAL 
const QoreValue& operator*()
 const { 
return v; }
   466     DLLEXPORT 
QoreValue getReferencedValue();
   479     DLLLOCAL 
operator bool()
 const {
   506     DLLLOCAL 
bool isTemp()
 const { 
return needs_deref; }
   509     DLLLOCAL 
void clearTemp() {
   515     DLLLOCAL 
operator bool()
 const {
   532         if (needs_deref != temp)
   540     DLLEXPORT 
void ensureReferencedValue();
   544     DLLLOCAL T* takeReferencedNode() {
   555     DLLEXPORT 
QoreValue getReferencedValue();
   561             return v.takeNodeIntern();
   571             return v.takeNodeIntern();
   585     DLLEXPORT 
QoreValue takeReferencedValue();
   589     DLLLOCAL 
void sanitize();
   627     DLLLOCAL 
int evalIntern(
const QoreValue exp);
   631 DLLEXPORT 
extern const char* qoreBoolTypeName;
   633 DLLEXPORT 
extern const char* qoreIntTypeName;
   635 DLLEXPORT 
extern const char* qoreFloatTypeName;
 double f
for double values 
Definition: QoreValue.h:59
 
base class for holding a QoreValue object 
Definition: QoreValue.h:422
 
#define QV_Int
for integer values 
Definition: QoreValue.h:44
 
this is the union that stores values in QoreValue 
Definition: QoreValue.h:56
 
allows storing a value and setting a boolean flag that indicates if the value should be dereference i...
Definition: QoreValue.h:485
 
evaluates an AbstractQoreNode and dereferences the stored value in the destructor ...
Definition: QoreValue.h:593
 
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:323
 
bool needs_deref
flag indicating if the value should be dereferenced in the destructor or not 
Definition: QoreValue.h:492
 
Qore's string type supported by the QoreEncoding class. 
Definition: QoreString.h:81
 
ExceptionSink * xsink
for possible Qore-language exceptions 
Definition: QoreValue.h:427
 
used in QoreValue::get() 
Definition: QoreValue.h:67
 
#define QV_Node
for heap-allocated values 
Definition: QoreValue.h:46
 
namespace for implementation details of QoreValue functions 
Definition: QoreValue.h:64
 
DLLLOCAL QoreValue takeValue(bool &nd)
returns the stored value and sets the dereference flag as an output variable 
Definition: QoreValue.h:568
 
#define QV_Bool
for boolean values 
Definition: QoreValue.h:43
 
QoreValue v
the value held 
Definition: QoreValue.h:425
 
The main value class in Qore, designed to be passed by value. 
Definition: QoreValue.h:262
 
AbstractQoreNode * n
for all heap-allocated values 
Definition: QoreValue.h:60
 
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
 
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
 
int64 i
for integer values 
Definition: QoreValue.h:58
 
#define QV_Float
for floating-point values 
Definition: QoreValue.h:45
 
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:70
 
bool b
for boolean values 
Definition: QoreValue.h:57
 
holds an object and dereferences it in the destructor 
Definition: QoreValue.h:452
 
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values ...