Qore Programming Language 1.19.5
Loading...
Searching...
No Matches
QoreSimpleValue Class Reference

Base value class; parent of QoreValue; designed to be passed by value. More...

#include <QoreValue.h>

Inheritance diagram for QoreSimpleValue:
[legend]
Collaboration diagram for QoreSimpleValue:
[legend]

Public Member Methods

DLLLOCAL QoreSimpleValueassign (AbstractQoreNode *n)
 assigns a new value to the object and returns a reference to the object; any current value is overwritten
 
DLLLOCAL QoreSimpleValueassign (bool b)
 assigns a new value to the object and returns a reference to the object; any current value is overwritten
 
DLLLOCAL QoreSimpleValueassign (const QoreSimpleValue &val)
 assigns a new value to the object and returns a reference to the object; any current value is overwritten
 
DLLLOCAL QoreSimpleValueassign (double f)
 assigns a new value to the object and returns a reference to the object; any current value is overwritten
 
DLLLOCAL QoreSimpleValueassign (int64 i)
 assigns a new value to the object and returns a reference to the object; any current value is overwritten
 
DLLEXPORT void clear ()
 unconditionally set the QoreValue to QoreNothingNode (does not dereference any possible contained AbstractQoreNode ptr)
 
DLLEXPORT void discard (ExceptionSink *xsink)
 dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values
 
template<typename T >
DLLLOCAL detail::QoreValueCastHelper< T >::Result get ()
 returns the value as the given type More...
 
template<typename T >
DLLLOCAL detail::QoreValueCastHelper< constT >::Result get () const
 returns the value as the given type More...
 
DLLEXPORT int64 getAsBigInt () const
 returns the value as an int
 
DLLEXPORT bool getAsBool () const
 returns the value as a bool
 
DLLEXPORT double getAsFloat () const
 returns the value as a float
 
DLLEXPORT AbstractQoreNodegetInternalNode ()
 returns any AbstractQoreNode value held; if type != QV_Node, returns nullptr
 
DLLEXPORT const AbstractQoreNodegetInternalNode () const
 returns any AbstractQoreNode value held; if type != QV_Node, returns nullptr
 
DLLEXPORT qore_type_t getType () const
 returns the type of value contained
 
DLLEXPORT const char * getTypeName () const
 returns a string type description of the value contained (ex: "nothing" for a null AbstractQoreNode pointer)
 
DLLEXPORT bool hasEffect () const
 return true if the value needs evaluation and has a side effect
 
DLLEXPORT bool isConstant () const
 returns true if the value is a constant value (does not require evaluation) More...
 
DLLEXPORT bool isEqualHard (const QoreValue v) const
 returns trus if the argument value is equal to the current value without any type conversions
 
DLLEXPORT bool isNothing () const
 returns true if the object contains NOTHING
 
DLLEXPORT bool isNull () const
 returns true if the object contains NULL
 
DLLEXPORT bool isNullOrNothing () const
 returns true if the object contains NOTHING or NULL
 
DLLEXPORT bool isScalar () const
 returns true if the value is a scalar (int, bool, float, number, string) More...
 
DLLEXPORT bool isValue () const
 returns true if the object holds a value, false if it holds an expression
 
DLLEXPORT bool needsEval () const
 return true if the value needs evaluation
 
DLLEXPORT operator bool () const
 returns true if the value is not NOTHING
 
DLLEXPORT void set (AbstractQoreNode *n)
 assigns a new value to the object; any current value is overwritten
 
DLLLOCAL void set (bool b)
 assigns a boolean value to the object; any current value is overwritten
 
DLLEXPORT void set (const QoreSimpleValue &val)
 assigns a new value to the object; any current value is overwritten
 
DLLLOCAL void set (double f)
 assigns a floating-point value to the object; any current value is overwritten
 
DLLLOCAL void set (int64 i)
 assigns an integer value to the object; any current value is overwritten
 
template<typename T >
DLLLOCAL T * take ()
 returns a pointer to an object of the given class; takes the pointer from the object; the caller owns the reference returned More...
 
DLLEXPORT AbstractQoreNodetakeNode ()
 returns a referenced AbstractQoreNode pointer leaving "this" empty (value is taken from "this"); the caller owns the reference returned; do not call with a simple value (int, float or bool) More...
 

Public Attributes

valtype_t type
 indicates the value that the union is holding
 
qore_value_u v
 the actual value is stored here
 

Private Member Methods

DLLEXPORT AbstractQoreNodetakeNodeIntern ()
 returns the internal AbstractQoreNode pointer, does not check that type == QV_Node, leaves the object empty
 

Detailed Description

Base value class; parent of QoreValue; designed to be passed by value.

Member Function Documentation

◆ get() [1/2]

template<typename T >
DLLLOCAL detail::QoreValueCastHelper< T >::Result QoreSimpleValue::get ( )
inline

returns the value as the given type

Note
that if a pointer type is given and the object does not contain a node (i.e. type != QV_Node), then this call will cause a segfault, however it is always legal to cast to simple types (int64, bool, float), in which case type conversions are performed

References type.

Referenced by AbstractQoreThreadResource::cleanup(), get_hard_value_or_nothing_param(), ValueHolder::releaseAs(), and test_reference_param().

◆ get() [2/2]

template<typename T >
DLLLOCAL detail::QoreValueCastHelper< constT >::Result QoreSimpleValue::get ( ) const
inline

returns the value as the given type

Note
that if a pointer type is given and the object does not contain a node (i.e. type != QV_Node), then this call will cause a segfault, however it is always legal to cast to simple types (int64, bool, float), in which case type conversions are performed

References type.

◆ isConstant()

DLLEXPORT bool QoreSimpleValue::isConstant ( ) const

returns true if the value is a constant value (does not require evaluation)

returns true if the type is a constant int, bool, float, number, string, list, hash, date, binary, object, nothing, or null value

Since
Qore 1.1

◆ isScalar()

DLLEXPORT bool QoreSimpleValue::isScalar ( ) const

returns true if the value is a scalar (int, bool, float, number, string)

Since
Qore 1.0

◆ take()

template<typename T >
DLLLOCAL T * QoreSimpleValue::take ( )
inline

returns a pointer to an object of the given class; takes the pointer from the object; the caller owns the reference returned

will assert() in debug mode if the object does not contain a value of the requested type or if type != QV_Node

References qore_value_u::n, QV_Node, type, and v.

Referenced by ValueOptionalRefHolder::takeReferencedNode().

◆ takeNode()

DLLEXPORT AbstractQoreNode * QoreSimpleValue::takeNode ( )

returns a referenced AbstractQoreNode pointer leaving "this" empty (value is taken from "this"); the caller owns the reference returned; do not call with a simple value (int, float or bool)

Note
this call will assert() in debug mode if the value is an int, float or bool

Referenced by ValueOptionalRefHolder::takeNode().


The documentation for this class was generated from the following file: