Qore Programming Language
1.12.0
|
helper class to manage variable references passed to functions and class methods, stack only, cannot be dynamically allocated More...
#include <QoreTypeSafeReferenceHelper.h>
Public Member Methods | |
DLLEXPORT | QoreTypeSafeReferenceHelper (const ReferenceNode *ref, AutoVLock &vl, ExceptionSink *xsink) |
initializes the object and tries to get the pointer to the pointer of the lvalue expression target More... | |
DLLEXPORT | QoreTypeSafeReferenceHelper (const ReferenceNode *ref, ExceptionSink *xsink) |
initializes the object and tries to get the pointer to the pointer of the lvalue expression target More... | |
DLLEXPORT | ~QoreTypeSafeReferenceHelper () |
destroys the object | |
DLLEXPORT int | assign (QoreValue val) |
assigns a value to the reference, assumes the reference is valid More... | |
DLLEXPORT qore_type_t | getType () const |
returns the type of the reference's value More... | |
DLLEXPORT const char * | getTypeName () const |
returns the type name of the reference's value More... | |
DLLEXPORT AbstractQoreNode * | getUnique (ExceptionSink *xsink) |
returns a pointer to the value with a unique reference count (so it can be updated in place), assumes the reference is valid and the lvalue holds a reference-counted AbstractQoreNode*, if not, this call will cause a segfault More... | |
DLLEXPORT const QoreValue | getValue () const |
returns the reference's value More... | |
DLLEXPORT | operator bool () const |
returns true if the reference is valid, false if not More... | |
helper class to manage variable references passed to functions and class methods, stack only, cannot be dynamically allocated
Takes care of safely accessing ReferenceNode objects, for example when they are passed as arguments to a builtin function or method. Locks are automatically acquired in the constructor if necessary and released in the destructor. The constructor could raise a Qore-language exception if there is a deadlock acquiring any locks to access the ReferenceNode's value as given by the lvalue expression, so the object should be checked for this state right after the constructor as in the following example:
DLLEXPORT QoreTypeSafeReferenceHelper::QoreTypeSafeReferenceHelper | ( | const ReferenceNode * | ref, |
ExceptionSink * | xsink | ||
) |
initializes the object and tries to get the pointer to the pointer of the lvalue expression target
ref | the ReferenceNode to use |
xsink | Qore-language exceptions raised will be added here (for example, a deadlock accessing the object) |
DLLEXPORT QoreTypeSafeReferenceHelper::QoreTypeSafeReferenceHelper | ( | const ReferenceNode * | ref, |
AutoVLock & | vl, | ||
ExceptionSink * | xsink | ||
) |
initializes the object and tries to get the pointer to the pointer of the lvalue expression target
ref | the ReferenceNode to use |
vl | this argument is ignored in this deprecated version of the function |
xsink | Qore-language exceptions raised will be added here (for example, a deadlock accessing the object) |
DLLEXPORT int QoreTypeSafeReferenceHelper::assign | ( | QoreValue | val | ) |
assigns a value to the reference, assumes the reference is valid
val | the value to assign (must be already referenced for the assignment) |
DLLEXPORT qore_type_t QoreTypeSafeReferenceHelper::getType | ( | ) | const |
returns the type of the reference's value
DLLEXPORT const char* QoreTypeSafeReferenceHelper::getTypeName | ( | ) | const |
returns the type name of the reference's value
DLLEXPORT AbstractQoreNode* QoreTypeSafeReferenceHelper::getUnique | ( | ExceptionSink * | xsink | ) |
returns a pointer to the value with a unique reference count (so it can be updated in place), assumes the reference is valid and the lvalue holds a reference-counted AbstractQoreNode*, if not, this call will cause a segfault
xsink | required for the call to AbstractQoreNode::deref() |
DLLEXPORT const QoreValue QoreTypeSafeReferenceHelper::getValue | ( | ) | const |
returns the reference's value
DLLEXPORT QoreTypeSafeReferenceHelper::operator bool | ( | ) | const |
returns true if the reference is valid, false if not
false will only be returned if a Qore-language exception was raised in the constructor