17#ifndef __LOCALPOINTER_H__
18#define __LOCALPOINTER_H__
41#if U_SHOW_CPLUSPLUS_API
160 static void * U_EXPORT2
operator new(
size_t size);
161 static void * U_EXPORT2
operator new[](
size_t size);
162#if U_HAVE_PLACEMENT_NEW
163 static void * U_EXPORT2
operator new(size_t,
void *
ptr);
290#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \
291 class LocalPointerClassName : public LocalPointerBase<Type> { \
293 explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \
294 ~LocalPointerClassName() { closeFunction(ptr); } \
295 void adoptInstead(Type *p) { \
296 closeFunction(ptr); \
T & operator[](ptrdiff_t i) const
Array item access (writable).
void adoptInstead(T *p)
Deletes the array it owns, and adopts (takes ownership of) the one passed in.
LocalArray(T *p=NULL)
Constructor takes ownership.
~LocalArray()
Destructor deletes the array it owns.
T * getAlias() const
Access without ownership change.
bool operator!=(const T *other) const
Comparison with a simple pointer, so that existing code with !=NULL need not be changed.
T * operator->() const
Access without ownership change.
void adoptInstead(T *p)
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
T * orphan()
Gives up ownership; the internal pointer becomes NULL.
UBool isNull() const
NULL check.
LocalPointerBase(T *p=NULL)
Constructor takes ownership.
~LocalPointerBase()
Destructor deletes the object it owns.
bool operator==(const T *other) const
Comparison with a simple pointer, so that existing code with ==NULL need not be changed.
UBool isValid() const
NULL check.
T & operator*() const
Access without ownership change.
~LocalPointer()
Destructor deletes the object it owns.
LocalPointer(T *p=NULL)
Constructor takes ownership.
void adoptInstead(T *p)
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
int8_t UBool
The ICU boolean type.
Basic definitions for ICU, for both C and C++ APIs.
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.