ReferenceArgumentHelper Class Reference

allows a reference to be passed as an argument to Qore code More...

#include <ReferenceArgumentHelper.h>

List of all members.

Public Member Functions

DLLEXPORT ReferenceArgumentHelper (AbstractQoreNode *val, ExceptionSink *xsink)
 creates a fake local variable assigned to "val" and creates a reference to the local variable
DLLEXPORT ~ReferenceArgumentHelper ()
 frees all memory still managed by the object
DLLEXPORT AbstractQoreNodegetArg () const
 returns the reference to the fake local variable for use in an argument list, the caller owns the reference returned
DLLEXPORT AbstractQoreNodegetOutputValue ()
 returns the value of the reference and leaves the reference empty, the caller owns the reference returned


Detailed Description

allows a reference to be passed as an argument to Qore code

this class creates a fake local variable and then creates a reference the local variable that can be used in an argument list to be passed to a function. Then the ReferenceArgumentHelper::getOutputValue() function can be called to retrieve the value of the local variable after the Qore-language code has been executed. This allows values to be passed by reference to Qore-language code and then the value of the variable read back out and processed.

    // create an argument list
    ReferenceHolder<QoreListNode> args(new QoreListNode(), &xsink);
    // instantiate "val" as a reference as the only argument in the argument list
    ReferenceArgumentHelper lvh("arg0", val, &xsink);
    args->push(lvh.getArg());

    // execute method "m_fixup" and discard any return value
    discard(m_fixup->eval(qore_obj, *args, &xsink), &xsink);

    // return the value of the reference after executing the method
    return lvh.getOutputValue();

Constructor & Destructor Documentation

DLLEXPORT ReferenceArgumentHelper::ReferenceArgumentHelper ( AbstractQoreNode val,
ExceptionSink xsink 
)

creates a fake local variable assigned to "val" and creates a reference to the local variable

Parameters:
val the value to assign to the local variable
xsink this value is saved to be used for dereferencing the fake local variable in the destructor


Member Function Documentation

DLLEXPORT AbstractQoreNode* ReferenceArgumentHelper::getArg (  )  const

returns the reference to the fake local variable for use in an argument list, the caller owns the reference returned

Returns:
the reference to the fake local variable for use in an argument list, the caller owns the reference returned

DLLEXPORT AbstractQoreNode* ReferenceArgumentHelper::getOutputValue (  ) 

returns the value of the reference and leaves the reference empty, the caller owns the reference returned

Returns:
the value of the reference and leaves the reference empty, the caller owns the reference returned


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

Generated on Mon Oct 26 09:09:50 2009 for Qore Programming Language by  doxygen 1.5.6