rcolyer.net
RC Lib  Version 201607061602
Public Member Functions | List of all members
RC::Ptr< T > Class Template Reference

A safe pointer class that throws an RC::ErrorMsgNull if a null dereference is attempted. More...

#include <Ptr.h>

Public Member Functions

 Ptr (T *t_ptr=NULL)
 Default constructor assigning the value of the pointer. More...
 
template<class Tderived >
 Ptr (const APtr< Tderived > &other)
 A constructor which obtains a non-reference-counted copy of an APtr. More...
 
template<class Tderived >
 Ptr (const RevPtr< Tderived > &other)
 A constructor which obtains a non-revokable copy of a RevPtr. More...
 
template<class Tderived >
 Ptr (const Ptr< Tderived > &other)
 Copy constructor. More...
 
void Delete ()
 Deletes the object being pointed to and nulls the pointer.
 
T * Raw () const
 Returns a direct reference to the enclosed pointer. More...
 
void Assert () const
 Throws RC::ErrorMsgNull if the pointer is null.
 
bool IsSet () const
 True if the pointer is non-NULL. More...
 
bool IsNull () const
 True if the pointer is NULL. More...
 
T & operator* ()
 Dereferences the pointer, or throws an exception if null. More...
 
const T & operator* () const
 Const version of operator*()
 
T * operator-> ()
 Provides access to the enclosed pointer, or throws RC::ErrorMsgNull if null. More...
 
const T * operator-> () const
 Const version of operator->()
 
 operator T * () const
 Implicitly casts to the enclosed pointer, without null checking.
 
template<class Type >
Ptr< Type > Cast ()
 Dynamically casts to an RC::Ptr of the type used as a template parameter on this function. More...
 
template<class Type >
const Ptr< Type > Cast () const
 Const version of Cast()
 
template<class Type >
bool CanCast () const
 True if it can dynamically cast to this type.
 
template<class Type >
Type & As ()
 Dynamically casts and dereferences to the type presented as a template parameter, or throws ErrorMsgCast if it fails.
 
template<class Type >
const Type & As () const
 Const version of As()
 
T & As ()
 Dereference as the default type. More...
 
const T & As () const
 Const version of operator*()
 

Detailed Description

template<class T>
class RC::Ptr< T >

A safe pointer class that throws an RC::ErrorMsgNull if a null dereference is attempted.

See also
APtr
RevPtr

Constructor & Destructor Documentation

template<class T>
RC::Ptr< T >::Ptr ( T *  t_ptr = NULL)
inline

Default constructor assigning the value of the pointer.

Parameters
t_ptrThe new pointer value.
template<class T>
template<class Tderived >
RC::Ptr< T >::Ptr ( const APtr< Tderived > &  other)
inline

A constructor which obtains a non-reference-counted copy of an APtr.

Parameters
otherThe APtr from which a pointer should be extracted.
template<class T>
template<class Tderived >
RC::Ptr< T >::Ptr ( const RevPtr< Tderived > &  other)
inline

A constructor which obtains a non-revokable copy of a RevPtr.

Parameters
otherThe RevPtr from which a pointer should be extracted.
template<class T>
template<class Tderived >
RC::Ptr< T >::Ptr ( const Ptr< Tderived > &  other)
inline

Copy constructor.

Parameters
otherThe Ptr to copy.

Member Function Documentation

template<class T>
T& RC::Ptr< T >::As ( )
inline

Dereference as the default type.

See also
operator()
template<class T>
template<class Type >
Ptr<Type> RC::Ptr< T >::Cast ( )
inline

Dynamically casts to an RC::Ptr of the type used as a template parameter on this function.

The Ptr is NULL if the cast fails.

template<class T>
bool RC::Ptr< T >::IsNull ( ) const
inline

True if the pointer is NULL.

Returns
True if the pointer is NULL.
template<class T>
bool RC::Ptr< T >::IsSet ( ) const
inline

True if the pointer is non-NULL.

Returns
True if the pointer is non-NULL.
template<class T>
T& RC::Ptr< T >::operator* ( )
inline

Dereferences the pointer, or throws an exception if null.

The exception thrown is RC::ErrorMsgNull.

Returns
A reference to the dereferenced object.
template<class T>
T* RC::Ptr< T >::operator-> ( )
inline

Provides access to the enclosed pointer, or throws RC::ErrorMsgNull if null.

Returns
The enclosed pointer.
template<class T>
T* RC::Ptr< T >::Raw ( ) const
inline

Returns a direct reference to the enclosed pointer.

The reference is read/write, so it can be used as a function parameter which updates the value of this pointer.

Returns
A reference to the enclosed pointer.

The documentation for this class was generated from the following file:
email address
— (c) 2015