Qore Programming Language - C/C++ Library  0.8.13.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreValue Struct Reference

The main value class in Qore, designed to be passed by value. More...

#include <QoreValue.h>

Collaboration diagram for QoreValue:

Public Member Functions

DLLEXPORT QoreValue ()
 creates with no value (i.e. QoreNothingNode)
 
DLLEXPORT QoreValue (bool b)
 creates as a bool
 
DLLEXPORT QoreValue (int i)
 creates as an int
 
DLLEXPORT QoreValue (unsigned int i)
 creates as an int
 
DLLEXPORT QoreValue (long i)
 creates as an int
 
DLLEXPORT QoreValue (unsigned long i)
 creates as an int
 
DLLEXPORT QoreValue (unsigned long long i)
 creates as an int
 
DLLEXPORT QoreValue (int64 i)
 creates as an int
 
DLLEXPORT QoreValue (double f)
 creates as a double
 
DLLEXPORT QoreValue (AbstractQoreNode *n)
 the QoreValue object takes the reference of the argument passed
 
DLLEXPORT QoreValue (const AbstractQoreNode *n)
 creates as the given object; does not reference n for the assignment to this object More...
 
DLLEXPORT QoreValue (const QoreValue &old)
 copies the value, in case type == QV_Node, no additional references are made in this function
 
DLLEXPORT AbstractQoreNodeassign (AbstractQoreNode *n)
 the QoreValue object takes the reference of the argument More...
 
DLLEXPORT AbstractQoreNodeassign (int64 n)
 sets the value of the object and returns any node value held previously More...
 
DLLEXPORT AbstractQoreNodeassign (double n)
 sets the value of the object and returns any node value held previously More...
 
DLLEXPORT AbstractQoreNodeassign (bool n)
 sets the value of the object and returns any node value held previously More...
 
DLLEXPORT AbstractQoreNodeassignAndSanitize (const QoreValue n)
 sets the value of the object and returns any node value held previously More...
 
DLLEXPORT AbstractQoreNodeassignNothing ()
 sets the value of the object to QoreNothingNode and returns any node value held previously More...
 
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
< const T >::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 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
 
DLLEXPORT QoreStringgetAsString (bool &del, int foff, ExceptionSink *xsink) const
 returns the string value with optional formatting of the contained node
 
DLLEXPORT const char * getFullTypeName () const
 returns a string type description of the full type of the value contained (ex: "nothing" for a null AbstractQoreNode pointer); differs from the return value of getTypeName() for complex types (ex: "hash<string, int>")
 
DLLEXPORT AbstractQoreNodegetInternalNode ()
 returns any AbstractQoreNode value held; if type != QV_Node, returns NULL
 
DLLEXPORT const AbstractQoreNodegetInternalNode () const
 returns any AbstractQoreNode value held; if type != QV_Node, returns NULL
 
DLLEXPORT AbstractQoreNodegetReferencedValue () const
 returns a referenced AbstractQoreNode pointer; leaving the "this" untouched; the caller owns the reference returned
 
DLLEXPORT qore_type_t getType () const
 returns the type of value contained
 
DLLEXPORT const QoreTypeInfo * getTypeInfo () const
 returns the type of the value More...
 
DLLEXPORT const char * getTypeName () const
 returns a string type description of the value contained (ex: "nothing" for a null AbstractQoreNode pointer)
 
DLLEXPORT bool hasNode () const
 returns true if the object contains a non-null AbstractQoreNode pointer (ie type == QV_Node && v.n is not 0)
 
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 isEqualSoft (const QoreValue v, ExceptionSink *xsink) const
 returns trus if the argument value is equal to the current value with 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 QoreValueoperator= (const QoreValue &n)
 assigns a new value
 
DLLEXPORT void ref () const
 references the contained value if type == QV_Node
 
DLLEXPORT QoreValue refSelf () const
 references the contained value if type == QV_Node, returns itself
 
DLLEXPORT void sanitize ()
 converts any node pointers to efficient representations if possible and dereferences the node value contained
 
DLLEXPORT void swap (QoreValue &val)
 exchanges the values
 
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 AbstractQoreNodetakeIfNode ()
 returns a referenced AbstractQoreNode pointer only if the contained value is an AbstractQoreNode pointer, in which case "this" is left empty (the value is taken from "this"); returns 0 if the object does not contain an AbstractQoreNode pointer (type != QV_Node)
 
DLLEXPORT AbstractQoreNodetakeNode ()
 returns a referenced AbstractQoreNode pointer leaving "this" empty (value is taken from "this"); the caller owns the reference returned
 

Public Attributes

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

Protected Member Functions

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

Friends

template<typename >
struct detail::QoreValueCastHelper
 
class ValueHolder
 
class ValueOptionalRefHolder
 

Detailed Description

The main value class in Qore, designed to be passed by value.

Constructor & Destructor Documentation

DLLEXPORT QoreValue::QoreValue ( const AbstractQoreNode n)

creates as the given object; does not reference n for the assignment to this object

sanitizes n (increases the reference of n if necessary), meaning that if possible, the value is converted to an immediate value in place (int, float, or bool)

if getType() == QV_Node after this assignment, then the node must be referenced for the assignment

Member Function Documentation

DLLEXPORT AbstractQoreNode* QoreValue::assign ( AbstractQoreNode n)

the QoreValue object takes the reference of the argument

Parameters
nthe new node value of the object, sets type to QV_Node
Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
DLLEXPORT AbstractQoreNode* QoreValue::assign ( int64  n)

sets the value of the object and returns any node value held previously

Parameters
nthe new value of the object; sets type to QV_Int
Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
DLLEXPORT AbstractQoreNode* QoreValue::assign ( double  n)

sets the value of the object and returns any node value held previously

Parameters
nthe new value of the object; sets type to QV_Float
Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
DLLEXPORT AbstractQoreNode* QoreValue::assign ( bool  n)

sets the value of the object and returns any node value held previously

Parameters
nthe new value of the object; sets type to QV_Bool
Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
DLLEXPORT AbstractQoreNode* QoreValue::assignAndSanitize ( const QoreValue  n)

sets the value of the object and returns any node value held previously

Parameters
nthe new value of the object
Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
DLLEXPORT AbstractQoreNode* QoreValue::assignNothing ( )

sets the value of the object to QoreNothingNode and returns any node value held previously

sets type to QV_Node

Returns
any node value held before; if type != QV_Node before the assignment, returns NULL
template<typename T >
DLLLOCAL detail::QoreValueCastHelper<T>::Result QoreValue::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 get_hard_value_or_nothing_param().

template<typename T >
DLLLOCAL detail::QoreValueCastHelper<const T>::Result QoreValue::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.

DLLEXPORT const QoreTypeInfo* QoreValue::getTypeInfo ( ) const

returns the type of the value

Since
Qore 0.8.13
template<typename T >
DLLLOCAL T* QoreValue::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().


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