Qore Programming Language - C/C++ Library 2.2.1
Loading...
Searching...
No Matches
ReferenceHolder< T > Class Template Reference

a templated class to manage a reference count of an object that can throw a Qore-language exception when dereferenced More...

#include <ReferenceHolder.h>

Collaboration diagram for ReferenceHolder< T >:
[legend]

Public Member Functions

DLLLOCAL ReferenceHolder (ExceptionSink *xsink_)
 creates an empty ReferenceHolder
DLLLOCAL ReferenceHolder (T *p_, ExceptionSink *xsink_)
 populates with object with data and the ExceptionSink pointer
DLLLOCAL ~ReferenceHolder ()
 calls deref(ExceptionSink *) on the pointer being managed if not 0
DLLLOCAL T ** getPtrPtr ()
 returns a pointer to the pointer being managed
DLLLOCAL T *& getRef ()
 returns a reference to the ptr being managed
DLLLOCAL operator bool () const
 returns true if a non-0 pointer is being managed
DLLLOCAL T * operator* ()
 returns the pointer being managed
DLLLOCAL const T * operator* () const
 returns the pointer being managed
DLLLOCAL T * operator-> ()
 returns the pointer being managed
DLLLOCAL const T * operator-> () const
 returns the pointer being managed
DLLLOCAL void operator= (T *nv)
 assigns a new pointer to the holder, dereferences the current pointer if any
DLLLOCAL T * release ()
 releases the pointer to the caller
DLLLOCAL T * swap (T *val)
 swaps the current value for a new one

Detailed Description

template<typename T = class AbstractQoreNode>
class ReferenceHolder< T >

a templated class to manage a reference count of an object that can throw a Qore-language exception when dereferenced

the destructor will call deref(ExceptionSink *)

ReferenceHolder<QoreQFont> holder(self->getReferencedPrivateData(CID_QFONT, xsink), xsink);
// the call to deref(ExceptionSink *) is automatic when the object goes out of scope
if (*xsink)
return 0;
return holder->styleHint();
DLLLOCAL ReferenceHolder(ExceptionSink *xsink_)
creates an empty ReferenceHolder
Definition ReferenceHolder.h:55

Member Function Documentation

◆ swap()

template<typename T = class AbstractQoreNode>
DLLLOCAL T * ReferenceHolder< T >::swap ( T * val)
inline

swaps the current value for a new one

Since
Qore 1.14

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