Guiliani  Version 2.6 revision 7293 (documentation build 12)
CGUIAutoPtr< T > Class Template Reference

Guiliani-implementation of an auto-pointer. More...

#include <GUIAutoPtr.h>

Public Types

typedef T element_type
 typedef of element type
 

Public Member Functions

 CGUIAutoPtr (CGUIAutoPtr< T > &kSource) throw ()
 
 CGUIAutoPtr (element_type *p, eC_Bool bIsArray) throw ()
 
 ~CGUIAutoPtr () throw ()
 
element_typeget () const throw ()
 
template<class Y >
 operator CGUIAutoPtr< Y > () throw ()
 Convert this auto pointer with type T to auto pointer with type Y.
 
element_typeoperator* () const throw ()
 
element_typeoperator-> () const throw ()
 
CGUIAutoPtr< T > & operator= (CGUIAutoPtr< T > &kSource) throw ()
 
CGUIAutoPtroperator= (element_type *p)
 
element_typerelease () throw ()
 
void reset (element_type *p=0) throw ()
 

Detailed Description

template<class T>
class CGUIAutoPtr< T >

Guiliani-implementation of an auto-pointer.

The CGUIAutoPtr template class describes an object that stores a pointer to a single allocated object of type T that ensures that the object to which it points gets destroyed automatically when control leaves a scope. In other words: If you allocate memory and assign it to an auto-pointer, the auto-pointer will delete this memory if it gets destructed.

A typical use-case example would be:

// Demo scope
{
// Construct a CGUIObject and hand over the pointer to an auto-pointer
CGUIAutoPtr<CGUIObject> pkObject(new CGUIObject(), false);
// pkObject gets destroyed at the end of scope and will automatically delete the CGUIObject which we created
}
Guiliani-implementation of an auto-pointer.
Definition: GUIAutoPtr.h:48
This is the Guiliani base class all controls are derived from.
Definition: GUIObject.h:81

A demo use-case where a UNICODE-String gets converted to an array of ASCII-characters:

eC_String kString("I am selling these fine leather jackets");
// Demo scope
{
// Convert string to ASCII. Note that we are allocating an ARRAY and must inform the auto-pointer about this,
// by supplying true as the second parameter.
CGUIAutoPtr<eC_Char> pcTempString(kString.ToASCII_Alloc(), true);
// pcTempString gets destroyed at the end of scope and will automatically delete the temporary eC_Char buffer
}

Constructor & Destructor Documentation

◆ CGUIAutoPtr() [1/2]

template<class T >
CGUIAutoPtr< T >::CGUIAutoPtr ( element_type p,
eC_Bool  bIsArray 
)
throw (
)
inlineexplicit

Constructor

Parameters
pPointer to object
bIsArrayWhether to allocate as array

◆ CGUIAutoPtr() [2/2]

template<class T >
CGUIAutoPtr< T >::CGUIAutoPtr ( CGUIAutoPtr< T > &  kSource)
throw (
)
inline

Copy-constructor.

Parameters
kSourceSource object to be copied. The pointer in the source will be set to NULL.

◆ ~CGUIAutoPtr()

template<class T >
CGUIAutoPtr< T >::~CGUIAutoPtr ( )
throw (
)
inline

Destructor.

Member Function Documentation

◆ get()

template<class T >
element_type * CGUIAutoPtr< T >::get ( ) const
throw (
)
inline

Extract pointer.

Returns
the pointer

◆ operator*()

template<class T >
element_type & CGUIAutoPtr< T >::operator* ( ) const
throw (
)
inline

dereference operator

Returns
the dereferenced pointer

◆ operator->()

template<class T >
element_type * CGUIAutoPtr< T >::operator-> ( ) const
throw (
)
inline

arrow operator

Returns
the pointer

◆ operator=() [1/2]

template<class T >
CGUIAutoPtr< T > & CGUIAutoPtr< T >::operator= ( CGUIAutoPtr< T > &  kSource)
throw (
)
inline

Operator= method.

Parameters
kSourceSource object to be copied. The source pointer will be set to NULL.
Returns
This instance.

◆ operator=() [2/2]

template<class T >
CGUIAutoPtr & CGUIAutoPtr< T >::operator= ( element_type p)
inline

Overloaded operator = deletes the old pointer and sets the pointer.

Parameters
p
Returns
the pointer

◆ release()

template<class T >
element_type * CGUIAutoPtr< T >::release ( )
throw (
)
inline

Release pointer. This class will not control the pointer anymore.

Returns
the pointer

◆ reset()

template<class T >
void CGUIAutoPtr< T >::reset ( element_type p = 0)
throw (
)
inline

Reset the pointer to other one, the original pointer will be deleted.

Parameters
p

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