"Fossies" - the Fresh Open Source Software Archive

Member "classicu_1_1LocalPointerBase.html" (3 Oct 2019, 32446 Bytes) of package /linux/misc/icu4c-65_1-docs.zip:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

ICU 65.1  65.1
Public Member Functions | Static Public Member Functions | Protected Attributes
icu::LocalPointerBase< T > Class Template Reference

"Smart pointer" base class; do not use directly: use LocalPointer etc. More...

#include <localpointer.h>

Inheritance diagram for icu::LocalPointerBase< T >:
icu::LocalArray< T > icu::LocalPointer< T >

Public Member Functions

 LocalPointerBase (T *p=NULL)
 Constructor takes ownership. More...
 
 ~LocalPointerBase ()
 Destructor deletes the object it owns. More...
 
UBool isNull () const
 NULL check. More...
 
UBool isValid () const
 NULL check. More...
 
bool operator== (const T *other) const
 Comparison with a simple pointer, so that existing code with ==NULL need not be changed. More...
 
bool operator!= (const T *other) const
 Comparison with a simple pointer, so that existing code with !=NULL need not be changed. More...
 
T * getAlias () const
 Access without ownership change. More...
 
T & operator* () const
 Access without ownership change. More...
 
T * operator-> () const
 Access without ownership change. More...
 
T * orphan ()
 Gives up ownership; the internal pointer becomes NULL. More...
 
void adoptInstead (T *p)
 Deletes the object it owns, and adopts (takes ownership of) the one passed in. More...
 

Static Public Member Functions

static void * operator new (size_t)=delete
 
static void * operator new[] (size_t)=delete
 

Protected Attributes

T * ptr
 Actual pointer. More...
 

Detailed Description

template<typename T>
class icu::LocalPointerBase< T >

"Smart pointer" base class; do not use directly: use LocalPointer etc.

Base class for smart pointer classes that do not throw exceptions.

Do not use this base class directly, since it does not delete its pointer. A subclass must implement methods that delete the pointer: Destructor and adoptInstead().

There is no operator T *() provided because the programmer must decide whether to use getAlias() (without transfer of ownership) or orphan() (with transfer of ownership and NULLing of the pointer).

See also
LocalPointer
LocalArray
U_DEFINE_LOCAL_OPEN_POINTER
Stable:
ICU 4.4

Definition at line 68 of file localpointer.h.

Constructor & Destructor Documentation

◆ LocalPointerBase()

template<typename T>
icu::LocalPointerBase< T >::LocalPointerBase ( T *  p = NULL)
inlineexplicit

Constructor takes ownership.

Parameters
psimple pointer to an object that is adopted
Stable:
ICU 4.4

Definition at line 82 of file localpointer.h.

◆ ~LocalPointerBase()

template<typename T>
icu::LocalPointerBase< T >::~LocalPointerBase ( )
inline

Destructor deletes the object it owns.

Subclass must override: Base class does nothing.

Stable:
ICU 4.4

Definition at line 88 of file localpointer.h.

Member Function Documentation

◆ adoptInstead()

template<typename T>
void icu::LocalPointerBase< T >::adoptInstead ( T *  p)
inline

Deletes the object it owns, and adopts (takes ownership of) the one passed in.

Subclass must override: Base class does not delete the object.

Parameters
psimple pointer to an object that is adopted
Stable:
ICU 4.4

Definition at line 153 of file localpointer.h.

◆ getAlias()

template<typename T>
T* icu::LocalPointerBase< T >::getAlias ( ) const
inline

Access without ownership change.

Returns
the pointer value
Stable:
ICU 4.4

Definition at line 122 of file localpointer.h.

◆ isNull()

template<typename T>
UBool icu::LocalPointerBase< T >::isNull ( ) const
inline

NULL check.

Returns
TRUE if ==NULL
Stable:
ICU 4.4

Definition at line 94 of file localpointer.h.

References NULL.

Referenced by icu::Locale::getKeywords(), and icu::Locale::getUnicodeKeywords().

◆ isValid()

template<typename T>
UBool icu::LocalPointerBase< T >::isValid ( ) const
inline

NULL check.

Returns
TRUE if !=NULL
Stable:
ICU 4.4

Definition at line 100 of file localpointer.h.

References NULL.

◆ operator!=()

template<typename T>
bool icu::LocalPointerBase< T >::operator!= ( const T *  other) const
inline

Comparison with a simple pointer, so that existing code with !=NULL need not be changed.

Parameters
othersimple pointer for comparison
Returns
true if this pointer value differs from other
Stable:
ICU 4.4

Definition at line 116 of file localpointer.h.

◆ operator*()

template<typename T>
T& icu::LocalPointerBase< T >::operator* ( ) const
inline

Access without ownership change.

Returns
the pointer value as a reference
Stable:
ICU 4.4

Definition at line 128 of file localpointer.h.

◆ operator->()

template<typename T>
T* icu::LocalPointerBase< T >::operator-> ( ) const
inline

Access without ownership change.

Returns
the pointer value
Stable:
ICU 4.4

Definition at line 134 of file localpointer.h.

◆ operator==()

template<typename T>
bool icu::LocalPointerBase< T >::operator== ( const T *  other) const
inline

Comparison with a simple pointer, so that existing code with ==NULL need not be changed.

Parameters
othersimple pointer for comparison
Returns
true if this pointer value equals other
Stable:
ICU 4.4

Definition at line 108 of file localpointer.h.

◆ orphan()

template<typename T>
T* icu::LocalPointerBase< T >::orphan ( )
inline

Gives up ownership; the internal pointer becomes NULL.

Returns
the pointer value; caller becomes responsible for deleting the object
Stable:
ICU 4.4

Definition at line 141 of file localpointer.h.

References NULL.

Field Documentation

◆ ptr

template<typename T>
T* icu::LocalPointerBase< T >::ptr
protected

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