Loading...
Searching...
No Matches
QoreValue.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreValue.h
Qore Programming Language
Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_QOREVALUE_H
#define _QORE_QOREVALUE_H
#include <cassert>
typedef unsigned char valtype_t;
#define QV_Bool (valtype_t)0
#define QV_Int (valtype_t)1
#define QV_Float (valtype_t)2
#define QV_Node (valtype_t)3
#define QV_Ref (valtype_t)4
// forward references
class AbstractQoreNode;
class QoreString;
struct QoreValue;
union qore_value_u {
bool b;
int64 i;
double f;
AbstractQoreNode* n;
};
namespace detail {
template<typename Type>
struct QoreValueCastHelper {
typedef Type * Result;
template<typename QV>
static Result cast(QV *qv, valtype_t type) {
assert(type == QV_Node);
assert(!qv->v.n || dynamic_cast<Result>(qv->v.n));
return reinterpret_cast<Result>(qv->v.n);
}
};
template<>
struct QoreValueCastHelper<bool> {
typedef bool Result;
template<typename QV>
static bool cast(QV *qv, valtype_t type) {
return qv->getAsBool();
}
};
template<>
struct QoreValueCastHelper<double> {
typedef double Result;
template<typename QV>
static double cast(QV *qv, valtype_t type) {
return qv->getAsFloat();
}
};
template<>
struct QoreValueCastHelper<int64> {
typedef int64 Result;
template<typename QV>
static int64 cast(QV *qv, valtype_t type) {
return qv->getAsBigInt();
}
};
} // namespace detail
class QoreSimpleValue {
public:
qore_value_u v;
valtype_t type;
DLLLOCAL void set(int64 i) {
type = QV_Int;
v.i = i;
}
DLLLOCAL void set(double f) {
type = QV_Float;
v.f = f;
}
DLLLOCAL void set(bool b) {
type = QV_Bool;
v.b = b;
}
DLLEXPORT void set(QoreSimpleValue val);
DLLEXPORT void set(AbstractQoreNode* n);
DLLLOCAL QoreSimpleValue& assign(QoreSimpleValue& val) {
set(val);
return *this;
}
DLLLOCAL QoreSimpleValue& assign(int64 i) {
set(i);
return *this;
}
DLLLOCAL QoreSimpleValue& assign(double f) {
set(f);
return *this;
}
DLLLOCAL QoreSimpleValue& assign(bool b) {
set(b);
return *this;
}
DLLLOCAL QoreSimpleValue& assign(AbstractQoreNode* n) {
set(n);
return *this;
}
DLLEXPORT qore_type_t getType() const;
DLLEXPORT const char* getTypeName() const;
DLLEXPORT AbstractQoreNode* takeNode();
DLLEXPORT AbstractQoreNode* getInternalNode();
DLLEXPORT const AbstractQoreNode* getInternalNode() const;
DLLEXPORT void clear();
DLLEXPORT void discard(ExceptionSink* xsink);
template<typename T>
DLLLOCAL T* take() {
assert(type == QV_Node);
assert(dynamic_cast<T*>(v.n));
T* rv = reinterpret_cast<T*>(v.n);
v.n = 0;
return rv;
}
template<typename T>
DLLLOCAL typename detail::QoreValueCastHelper<T>::Result get() {
return detail::QoreValueCastHelper<T>::cast(this, type);
}
template<typename T>
DLLLOCAL typename detail::QoreValueCastHelper<const T>::Result get() const {
return detail::QoreValueCastHelper<const T>::cast(this, type);
}
DLLEXPORT bool getAsBool() const;
DLLEXPORT int64 getAsBigInt() const;
DLLEXPORT double getAsFloat() const;
DLLEXPORT bool hasEffect() const;
DLLEXPORT bool isNothing() const;
DLLEXPORT bool isNull() const;
DLLEXPORT bool isNullOrNothing() const;
DLLEXPORT bool isValue() const;
DLLEXPORT bool needsEval() const;
DLLEXPORT bool isScalar() const;
DLLEXPORT bool isConstant() const;
DLLEXPORT operator bool() const;
protected:
DLLEXPORT AbstractQoreNode* takeNodeIntern();
};
struct QoreValue : public QoreSimpleValue {
friend class ValueHolder;
friend class ValueOptionalRefHolder;
template<typename> friend struct detail::QoreValueCastHelper;
public:
DLLEXPORT QoreValue();
DLLEXPORT QoreValue(bool b);
DLLEXPORT QoreValue(int i);
DLLEXPORT QoreValue(unsigned int i);
DLLEXPORT QoreValue(long i);
DLLEXPORT QoreValue(unsigned long i);
DLLEXPORT QoreValue(unsigned long long i);
DLLEXPORT QoreValue(int64 i);
DLLEXPORT QoreValue(double f);
DLLEXPORT QoreValue(AbstractQoreNode* n);
DLLEXPORT QoreValue(const AbstractQoreNode* n);
DLLEXPORT QoreValue(const QoreSimpleValue& v);
DLLEXPORT QoreValue(const QoreValue& old);
DLLEXPORT void swap(QoreValue& val);
DLLEXPORT void ref() const;
DLLEXPORT QoreValue refSelf() const;
DLLEXPORT AbstractQoreNode* assign(const QoreValue n);
DLLEXPORT AbstractQoreNode* assign(AbstractQoreNode* n);
DLLEXPORT AbstractQoreNode* assign(int64 n);
DLLEXPORT AbstractQoreNode* assign(double n);
DLLEXPORT AbstractQoreNode* assign(bool n);
DLLEXPORT AbstractQoreNode* assignNothing();
DLLEXPORT bool isEqualSoft(const QoreValue v, ExceptionSink* xsink) const;
DLLEXPORT bool isEqualHard(const QoreValue v) const;
DLLEXPORT bool isEqualValue(const QoreValue v);
DLLEXPORT void sanitize();
DLLEXPORT QoreValue& operator=(const QoreValue& n);
DLLEXPORT QoreValue& operator=(const QoreSimpleValue& n);
DLLEXPORT void discard(ExceptionSink* xsink);
DLLEXPORT int getAsString(QoreString& str, int format_offset, ExceptionSink *xsink) const;
DLLEXPORT QoreString* getAsString(bool& del, int foff, ExceptionSink* xsink) const;
DLLEXPORT QoreValue eval(ExceptionSink* xsink) const;
DLLEXPORT QoreValue eval(bool& needs_deref, ExceptionSink* xsink) const;
//DLLEXPORT QoreValue refSelf() const;
DLLEXPORT AbstractQoreNode* takeIfNode();
DLLEXPORT const QoreTypeInfo* getTypeInfo() const;
DLLEXPORT const QoreTypeInfo* getFullTypeInfo() const;
DLLEXPORT const char* getFullTypeName() const;
DLLEXPORT const char* getFullTypeName(bool with_namespaces) const;
DLLEXPORT bool hasNode() const;
DLLEXPORT bool isReferenceCounted() const;
DLLEXPORT bool derefCanThrowException() const;
};
class ValueHolderBase {
protected:
QoreValue v;
ExceptionSink* xsink;
public:
DLLLOCAL ValueHolderBase(ExceptionSink* xs) : xsink(xs) {
}
DLLLOCAL ValueHolderBase(QoreValue n_v, ExceptionSink* xs) : v(n_v), xsink(xs) {
}
DLLLOCAL QoreValue* operator->() { return &v; }
DLLLOCAL const QoreValue* operator->() const { return &v; }
DLLLOCAL QoreValue& operator*() { return v; }
DLLLOCAL const QoreValue& operator*() const { return v; }
};
class ValueHolder : public ValueHolderBase {
public:
DLLLOCAL ValueHolder(ExceptionSink* xs) : ValueHolderBase(xs) {
}
DLLLOCAL ValueHolder(QoreValue n_v, ExceptionSink* xs) : ValueHolderBase(n_v, xs) {
}
DLLEXPORT ~ValueHolder();
DLLEXPORT QoreValue getReferencedValue();
DLLEXPORT QoreValue release();
DLLLOCAL QoreValue& operator=(QoreValue nv) {
v.discard(xsink);
v = nv;
return v;
}
DLLLOCAL operator bool() const {
return (bool)v;
}
};
class ValueOptionalRefHolder : public ValueHolderBase {
private:
// not implemented
DLLLOCAL QoreValue& operator=(QoreValue& nv);
protected:
bool needs_deref;
public:
DLLLOCAL ValueOptionalRefHolder(QoreValue n_v, bool nd, ExceptionSink* xs) : ValueHolderBase(n_v, xs), needs_deref(nd) {
}
DLLLOCAL ValueOptionalRefHolder(ExceptionSink* xs) : ValueHolderBase(xs), needs_deref(false) {
}
DLLEXPORT ~ValueOptionalRefHolder();
DLLLOCAL bool isTemp() const { return needs_deref; }
DLLLOCAL void clearTemp() {
if (needs_deref)
needs_deref = false;
}
DLLLOCAL operator bool() const {
return (bool)v;
}
DLLLOCAL void setValue(QoreValue nv) {
if (needs_deref) {
v.discard(xsink);
needs_deref = false;
}
v = nv;
}
DLLLOCAL void setValue(QoreValue nv, bool temp) {
if (needs_deref)
v.discard(xsink);
if (needs_deref != temp)
needs_deref = temp;
v = nv;
}
// ensures that the held value is referenced
DLLEXPORT void ensureReferencedValue();
template<typename T>
DLLLOCAL T* takeReferencedNode() {
T* rv = v.take<T>();
if (needs_deref)
needs_deref = false;
else
rv->ref();
return rv;
}
DLLEXPORT QoreValue getReferencedValue();
DLLLOCAL AbstractQoreNode* takeNode(bool& nd) {
if (v.type == QV_Node) {
nd = needs_deref;
return v.takeNodeIntern();
}
nd = true;
return v.takeNode();
}
DLLLOCAL QoreValue takeValue(bool& nd) {
if (v.type == QV_Node) {
nd = needs_deref;
return v.takeNodeIntern();
}
nd = false;
return v;
}
DLLLOCAL void takeValueFrom(ValueOptionalRefHolder& val) {
if (needs_deref)
v.discard(xsink);
v = val.takeValue(needs_deref);
}
DLLEXPORT QoreValue takeReferencedValue();
};
class ValueEvalRefHolder : public ValueOptionalRefHolder {
public:
DLLEXPORT ValueEvalRefHolder(const AbstractQoreNode* exp, ExceptionSink* xs);
DLLEXPORT ValueEvalRefHolder(const QoreValue exp, ExceptionSink* xs);
DLLEXPORT ValueEvalRefHolder(ExceptionSink* xs);
DLLEXPORT int eval(const AbstractQoreNode* exp);
DLLEXPORT int eval(const QoreValue exp);
protected:
DLLLOCAL int evalIntern(const AbstractQoreNode* exp);
DLLLOCAL int evalIntern(const QoreValue exp);
};
DLLEXPORT extern const char* qoreBoolTypeName;
DLLEXPORT extern const char* qoreIntTypeName;
DLLEXPORT extern const char* qoreFloatTypeName;
#endif
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreSimpleValue
Base value class; parent of QoreValue; designed to be passed by value.
Definition: QoreValue.h:113
QoreSimpleValue::set
DLLLOCAL void set(double f)
assigns a floating-point value to the object; any current value is overwritten
Definition: QoreValue.h:127
QoreSimpleValue::type
valtype_t type
indicates the value that the union is holding
Definition: QoreValue.h:118
QoreSimpleValue::v
qore_value_u v
the actual value is stored here
Definition: QoreValue.h:116
QoreSimpleValue::getAsFloat
DLLEXPORT double getAsFloat() const
returns the value as a float
QoreSimpleValue::isValue
DLLEXPORT bool isValue() const
returns true if the object holds a value, false if it holds an expression
QoreSimpleValue::getInternalNode
DLLEXPORT const AbstractQoreNode * getInternalNode() const
returns any AbstractQoreNode value held; if type != QV_Node, returns nullptr
QoreSimpleValue::set
DLLEXPORT void set(AbstractQoreNode *n)
assigns a new value to the object; any current value is overwritten
QoreSimpleValue::assign
DLLLOCAL QoreSimpleValue & assign(bool b)
assigns a new value to the object and returns a reference to the object; any current value is overwri...
Definition: QoreValue.h:163
QoreSimpleValue::isNull
DLLEXPORT bool isNull() const
returns true if the object contains NULL
QoreSimpleValue::get
DLLLOCAL detail::QoreValueCastHelper< T >::Result get()
returns the value as the given type
Definition: QoreValue.h:214
QoreSimpleValue::getInternalNode
DLLEXPORT AbstractQoreNode * getInternalNode()
returns any AbstractQoreNode value held; if type != QV_Node, returns nullptr
QoreSimpleValue::getType
DLLEXPORT qore_type_t getType() const
returns the type of value contained
QoreSimpleValue::takeNodeIntern
DLLEXPORT AbstractQoreNode * takeNodeIntern()
returns the internal AbstractQoreNode pointer, does not check that type == QV_Node,...
QoreSimpleValue::assign
DLLLOCAL QoreSimpleValue & assign(QoreSimpleValue &val)
assigns a new value to the object and returns a reference to the object; any current value is overwri...
Definition: QoreValue.h:145
QoreSimpleValue::getTypeName
DLLEXPORT const char * getTypeName() const
returns a string type description of the value contained (ex: "nothing" for a null AbstractQoreNode p...
QoreSimpleValue::assign
DLLLOCAL QoreSimpleValue & assign(AbstractQoreNode *n)
assigns a new value to the object and returns a reference to the object; any current value is overwri...
Definition: QoreValue.h:169
QoreSimpleValue::isNullOrNothing
DLLEXPORT bool isNullOrNothing() const
returns true if the object contains NOTHING or NULL
QoreSimpleValue::set
DLLLOCAL void set(int64 i)
assigns an integer value to the object; any current value is overwritten
Definition: QoreValue.h:121
QoreSimpleValue::get
DLLLOCAL detail::QoreValueCastHelper< constT >::Result get() const
returns the value as the given type
Definition: QoreValue.h:223
QoreSimpleValue::isScalar
DLLEXPORT bool isScalar() const
returns true if the value is a scalar (int, bool, float, number, string)
QoreSimpleValue::isConstant
DLLEXPORT bool isConstant() const
returns true if the value is a constant value (does not require evaluation)
QoreSimpleValue::getAsBool
DLLEXPORT bool getAsBool() const
returns the value as a bool
QoreSimpleValue::discard
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values
QoreSimpleValue::hasEffect
DLLEXPORT bool hasEffect() const
return true if the value needs evaluation and has a side effect
QoreSimpleValue::take
DLLLOCAL T * take()
returns a pointer to an object of the given class; takes the pointer from the object; the caller owns...
Definition: QoreValue.h:201
QoreSimpleValue::assign
DLLLOCAL QoreSimpleValue & assign(int64 i)
assigns a new value to the object and returns a reference to the object; any current value is overwri...
Definition: QoreValue.h:151
QoreSimpleValue::set
DLLLOCAL void set(bool b)
assigns a boolean value to the object; any current value is overwritten
Definition: QoreValue.h:133
QoreSimpleValue::needsEval
DLLEXPORT bool needsEval() const
return true if the value needs evaluation
QoreSimpleValue::set
DLLEXPORT void set(QoreSimpleValue val)
assigns a new value to the object; any current value is overwritten
QoreSimpleValue::getAsBigInt
DLLEXPORT int64 getAsBigInt() const
returns the value as an int
QoreSimpleValue::clear
DLLEXPORT void clear()
unconditionally set the QoreValue to QoreNothingNode (does not dereference any possible contained Abs...
QoreSimpleValue::takeNode
DLLEXPORT AbstractQoreNode * takeNode()
returns a referenced AbstractQoreNode pointer leaving "this" empty (value is taken from "this"); the ...
QoreSimpleValue::isNothing
DLLEXPORT bool isNothing() const
returns true if the object contains NOTHING
QoreSimpleValue::assign
DLLLOCAL QoreSimpleValue & assign(double f)
assigns a new value to the object and returns a reference to the object; any current value is overwri...
Definition: QoreValue.h:157
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
ValueEvalRefHolder
evaluates an AbstractQoreNode and dereferences the stored value in the destructor
Definition: QoreValue.h:614
ValueEvalRefHolder::ValueEvalRefHolder
DLLEXPORT ValueEvalRefHolder(const AbstractQoreNode *exp, ExceptionSink *xs)
evaluates the exp argument
ValueEvalRefHolder::ValueEvalRefHolder
DLLEXPORT ValueEvalRefHolder(ExceptionSink *xs)
creates the object with with no evaluation
ValueEvalRefHolder::ValueEvalRefHolder
DLLEXPORT ValueEvalRefHolder(const QoreValue exp, ExceptionSink *xs)
evaluates the exp argument
ValueEvalRefHolder::evalIntern
DLLLOCAL int evalIntern(const QoreValue exp)
evaluates the argument, returns -1 for error, 0 = OK
ValueEvalRefHolder::eval
DLLEXPORT int eval(const AbstractQoreNode *exp)
evaluates the argument, returns -1 for error, 0 = OK
ValueEvalRefHolder::eval
DLLEXPORT int eval(const QoreValue exp)
evaluates the argument, returns -1 for error, 0 = OK
ValueEvalRefHolder::evalIntern
DLLLOCAL int evalIntern(const AbstractQoreNode *exp)
evaluates the argument, returns -1 for error, 0 = OK
ValueHolderBase
base class for holding a QoreValue object
Definition: QoreValue.h:447
ValueHolderBase::operator*
DLLLOCAL QoreValue & operator*()
returns the value being managed
Definition: QoreValue.h:470
ValueHolderBase::operator*
DLLLOCAL const QoreValue & operator*() const
returns the value being managed
Definition: QoreValue.h:473
ValueHolderBase::ValueHolderBase
DLLLOCAL ValueHolderBase(QoreValue n_v, ExceptionSink *xs)
creates the object with the given value
Definition: QoreValue.h:460
ValueHolderBase::xsink
ExceptionSink * xsink
for possible Qore-language exceptions
Definition: QoreValue.h:452
ValueHolderBase::operator->
DLLLOCAL const QoreValue * operator->() const
returns the value being managed
Definition: QoreValue.h:467
ValueHolderBase::ValueHolderBase
DLLLOCAL ValueHolderBase(ExceptionSink *xs)
creates an ampty object
Definition: QoreValue.h:456
ValueHolderBase::v
QoreValue v
the value held
Definition: QoreValue.h:450
ValueHolderBase::operator->
DLLLOCAL QoreValue * operator->()
returns the value being managed
Definition: QoreValue.h:464
ValueHolder
holds an object and dereferences it in the destructor
Definition: QoreValue.h:477
ValueHolder::~ValueHolder
DLLEXPORT ~ValueHolder()
dereferences any contained node
ValueHolder::release
DLLEXPORT QoreValue release()
returns a QoreValue object and leaves the current object empty; the caller owns any reference contain...
ValueHolder::operator=
DLLLOCAL QoreValue & operator=(QoreValue nv)
assigns the object, any currently-held value is dereferenced before the assignment
Definition: QoreValue.h:497
ValueHolder::ValueHolder
DLLLOCAL ValueHolder(QoreValue n_v, ExceptionSink *xs)
creates the object with the given value
Definition: QoreValue.h:484
ValueHolder::ValueHolder
DLLLOCAL ValueHolder(ExceptionSink *xs)
creates an empty object
Definition: QoreValue.h:480
ValueHolder::getReferencedValue
DLLEXPORT QoreValue getReferencedValue()
returns a referenced value; caller owns the reference; the current object is left undisturbed
ValueOptionalRefHolder
allows storing a value and setting a boolean flag that indicates if the value should be dereference i...
Definition: QoreValue.h:510
ValueOptionalRefHolder::isTemp
DLLLOCAL bool isTemp() const
returns true if the value is temporary (needs dereferencing)
Definition: QoreValue.h:531
ValueOptionalRefHolder::ValueOptionalRefHolder
DLLLOCAL ValueOptionalRefHolder(QoreValue n_v, bool nd, ExceptionSink *xs)
creates the object with the given values
Definition: QoreValue.h:521
ValueOptionalRefHolder::ValueOptionalRefHolder
DLLLOCAL ValueOptionalRefHolder(ExceptionSink *xs)
creates an empty object
Definition: QoreValue.h:525
ValueOptionalRefHolder::takeReferencedNode
DLLLOCAL T * takeReferencedNode()
returns the stored node value and leaves the current object empty
Definition: QoreValue.h:569
ValueOptionalRefHolder::takeValue
DLLLOCAL QoreValue takeValue(bool &nd)
returns the stored value and sets the dereference flag as an output variable
Definition: QoreValue.h:593
ValueOptionalRefHolder::setValue
DLLLOCAL void setValue(QoreValue nv)
assigns a new non-temporary value
Definition: QoreValue.h:545
ValueOptionalRefHolder::ensureReferencedValue
DLLEXPORT void ensureReferencedValue()
ValueOptionalRefHolder::takeReferencedValue
DLLEXPORT QoreValue takeReferencedValue()
returns a QoreValue after incrementing the reference count of any node value stored if necessary
ValueOptionalRefHolder::clearTemp
DLLLOCAL void clearTemp()
sets needs_deref = false
Definition: QoreValue.h:534
ValueOptionalRefHolder::takeNode
DLLLOCAL AbstractQoreNode * takeNode(bool &nd)
returns the stored AbstractQoreNode pointer and sets the dereference flag as an output variable
Definition: QoreValue.h:583
ValueOptionalRefHolder::getReferencedValue
DLLEXPORT QoreValue getReferencedValue()
returns a referenced value; caller owns the reference; the current object is not disturbed
ValueOptionalRefHolder::setValue
DLLLOCAL void setValue(QoreValue nv, bool temp)
assigns a new value
Definition: QoreValue.h:554
ValueOptionalRefHolder::needs_deref
bool needs_deref
flag indicating if the value should be dereferenced in the destructor or not
Definition: QoreValue.h:517
ValueOptionalRefHolder::takeValueFrom
DLLLOCAL void takeValueFrom(ValueOptionalRefHolder &val)
returns the stored value which must be dereferenced if it is a node object (i.e. type == QV_Node)
Definition: QoreValue.h:603
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
int64
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
detail
namespace for implementation details of QoreValue functions
Definition: QoreValue.h:64
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:276
QoreValue::assignNothing
DLLEXPORT AbstractQoreNode * assignNothing()
sets the value of the object to QoreNothingNode and returns any node value held previously
QoreValue::assign
DLLEXPORT AbstractQoreNode * assign(bool n)
sets the value of the object and returns any node value held previously
QoreValue::getFullTypeName
DLLEXPORT const char * getFullTypeName(bool with_namespaces) const
returns a string type description of the full type of the value contained (ex: "nothing" for a null A...
QoreValue::QoreValue
DLLEXPORT QoreValue(AbstractQoreNode *n)
the QoreValue object takes the reference of the argument passed
QoreValue::getAsString
DLLEXPORT int getAsString(QoreString &str, int format_offset, ExceptionSink *xsink) const
appends the string value of the contained node to the string argument with optional formatting
QoreValue::QoreValue
DLLEXPORT QoreValue(unsigned long i)
creates as an int
QoreValue::QoreValue
DLLEXPORT QoreValue(unsigned long long i)
creates as an int
QoreValue::QoreValue
DLLEXPORT QoreValue(const AbstractQoreNode *n)
creates as the given object; does not reference n for the assignment to this object
QoreValue::QoreValue
DLLEXPORT QoreValue(int i)
creates as an int
QoreValue::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo() const
returns the type of the value
QoreValue::discard
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values
QoreValue::QoreValue
DLLEXPORT QoreValue(double f)
creates as a double
QoreValue::QoreValue
DLLEXPORT QoreValue(int64 i)
creates as an int
QoreValue::getFullTypeName
DLLEXPORT const char * getFullTypeName() const
returns a string type description of the full type of the value contained (ex: "nothing" for a null A...
QoreValue::getAsString
DLLEXPORT QoreString * getAsString(bool &del, int foff, ExceptionSink *xsink) const
returns the string value with optional formatting of the contained node
QoreValue::isReferenceCounted
DLLEXPORT bool isReferenceCounted() const
returns true if the value holds a referenced-counted node
QoreValue::takeIfNode
DLLEXPORT AbstractQoreNode * takeIfNode()
returns a referenced value; leaving the "this" untouched; the caller owns the reference returned
QoreValue::QoreValue
DLLEXPORT QoreValue(unsigned int i)
creates as an int
QoreValue::swap
DLLEXPORT void swap(QoreValue &val)
exchanges the values
QoreValue::assign
DLLEXPORT AbstractQoreNode * assign(const QoreValue n)
sets the value of the object and returns any node value held previously
QoreValue::hasNode
DLLEXPORT bool hasNode() const
returns true if the object contains a non-null AbstractQoreNode pointer (ie type == QV_Node && v....
QoreValue::operator=
DLLEXPORT QoreValue & operator=(const QoreSimpleValue &n)
assigns a new value
QoreValue::QoreValue
DLLEXPORT QoreValue(const QoreValue &old)
copies the value, in case type == QV_Node, no additional references are made in this function
QoreValue::isEqualValue
DLLEXPORT bool isEqualValue(const QoreValue v)
returns true of the argument is exactly the same value as the current value, meaning also that if bot...
QoreValue::eval
DLLEXPORT QoreValue eval(ExceptionSink *xsink) const
evaluates the node and returns the result
QoreValue::getFullTypeInfo
DLLEXPORT const QoreTypeInfo * getFullTypeInfo() const
returns the exact type of the value; i.e. the class type for classes, hashdecl type for hashdecls
QoreValue::derefCanThrowException
DLLEXPORT bool derefCanThrowException() const
returns true if a dereference could theoretically throw an exception (an object is reachable from thi...
QoreValue::assign
DLLEXPORT AbstractQoreNode * assign(double n)
sets the value of the object and returns any node value held previously
QoreValue::QoreValue
DLLEXPORT QoreValue()
creates with no value (i.e. QoreNothingNode)
QoreValue::assign
DLLEXPORT AbstractQoreNode * assign(int64 n)
sets the value of the object and returns any node value held previously
QoreValue::QoreValue
DLLEXPORT QoreValue(long i)
creates as an int
QoreValue::isEqualHard
DLLEXPORT bool isEqualHard(const QoreValue v) const
returns trus if the argument value is equal to the current value without any type conversions
QoreValue::ref
DLLEXPORT void ref() const
references the contained value if type == QV_Node
QoreValue::QoreValue
DLLEXPORT QoreValue(const QoreSimpleValue &v)
creates the value from the argument
QoreValue::QoreValue
DLLEXPORT QoreValue(bool b)
creates as a bool
QoreValue::eval
DLLEXPORT QoreValue eval(bool &needs_deref, ExceptionSink *xsink) const
evaluates the node and returns the result
QoreValue::refSelf
DLLEXPORT QoreValue refSelf() const
references the contained value if type == QV_Node, returns itself
QoreValue::isEqualSoft
DLLEXPORT bool isEqualSoft(const QoreValue v, ExceptionSink *xsink) const
returns trus if the argument value is equal to the current value with type conversions
QoreValue::operator=
DLLEXPORT QoreValue & operator=(const QoreValue &n)
assigns a new value
QoreValue::sanitize
DLLEXPORT void sanitize()
converts any node pointers to efficient representations if possible and dereferences the node value c...
QoreValue::assign
DLLEXPORT AbstractQoreNode * assign(AbstractQoreNode *n)
the QoreValue object takes the reference of the argument
detail::QoreValueCastHelper
used in QoreValue::get()
Definition: QoreValue.h:67
qore_value_u
this is the union that stores values in QoreValue
Definition: QoreValue.h:56
qore_value_u::b
bool b
for boolean values
Definition: QoreValue.h:57
qore_value_u::n
AbstractQoreNode * n
for all heap-allocated values
Definition: QoreValue.h:60
qore_value_u::f
double f
for double values
Definition: QoreValue.h:59
qore_value_u::i
int64 i
for integer values
Definition: QoreValue.h:58