17 #ifndef __LOCALPOINTER_H__ 18 #define __LOCALPOINTER_H__ 41 #if U_SHOW_CPLUSPLUS_API 97 bool operator==(
const T *other)
const {
return ptr==other; }
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);
194 #ifndef U_HIDE_DRAFT_API 213 #if U_HAVE_RVALUE_REFERENCES 231 #ifndef U_HIDE_DRAFT_API 232 #if U_HAVE_RVALUE_REFERENCES 241 return moveFrom(src);
289 #ifndef U_HIDE_DRAFT_API 346 #ifndef U_HIDE_DRAFT_API 365 #if U_HAVE_RVALUE_REFERENCES 383 #ifndef U_HIDE_DRAFT_API 384 #if U_HAVE_RVALUE_REFERENCES 393 return moveFrom(src);
441 #ifndef U_HIDE_DRAFT_API 502 #if U_HAVE_RVALUE_REFERENCES 503 #define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \ 504 class LocalPointerClassName : public LocalPointerBase<Type> { \ 506 explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \ 507 LocalPointerClassName(LocalPointerClassName &&src) U_NOEXCEPT \ 508 : LocalPointerBase<Type>(src.ptr) { \ 511 ~LocalPointerClassName() { closeFunction(ptr); } \ 512 LocalPointerClassName &operator=(LocalPointerClassName &&src) U_NOEXCEPT { \ 513 return moveFrom(src); \ 515 LocalPointerClassName &moveFrom(LocalPointerClassName &src) U_NOEXCEPT { \ 516 closeFunction(ptr); \ 517 LocalPointerBase<Type>::ptr=src.ptr; \ 521 void swap(LocalPointerClassName &other) U_NOEXCEPT { \ 522 Type *temp=LocalPointerBase<Type>::ptr; \ 523 LocalPointerBase<Type>::ptr=other.ptr; \ 526 friend inline void swap(LocalPointerClassName &p1, LocalPointerClassName &p2) U_NOEXCEPT { \ 529 void adoptInstead(Type *p) { \ 530 closeFunction(ptr); \ 535 #define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \ 536 class LocalPointerClassName : public LocalPointerBase<Type> { \ 538 explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \ 539 ~LocalPointerClassName() { closeFunction(ptr); } \ 540 LocalPointerClassName &moveFrom(LocalPointerClassName &src) U_NOEXCEPT { \ 541 closeFunction(ptr); \ 542 LocalPointerBase<Type>::ptr=src.ptr; \ 546 void swap(LocalPointerClassName &other) U_NOEXCEPT { \ 547 Type *temp=LocalPointerBase<Type>::ptr; \ 548 LocalPointerBase<Type>::ptr=other.ptr; \ 551 friend inline void swap(LocalPointerClassName &p1, LocalPointerClassName &p2) U_NOEXCEPT { \ 554 void adoptInstead(Type *p) { \ 555 closeFunction(ptr); \ void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode)
Deletes the array it owns, and adopts (takes ownership of) the one passed in.
void adoptInstead(T *p)
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
bool operator==(const T *other) const
Comparison with a simple pointer, so that existing code with ==NULL need not be changed.
#define U_SUCCESS(x)
Does the error code indicate success?
LocalPointer(T *p, UErrorCode &errorCode)
Constructor takes ownership and reports an error if NULL.
LocalArray(T *p=NULL)
Constructor takes ownership.
T * getAlias() const
Access without ownership change.
T * operator->() const
Access without ownership change.
"Smart pointer" class, deletes objects via the standard C++ delete operator.
LocalArray(T *p, UErrorCode &errorCode)
Constructor takes ownership and reports an error if NULL.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void swap(LocalPointer< T > &other) U_NOEXCEPT
Swap pointers.
UBool isNull() const
NULL check.
T & operator*() const
Access without ownership change.
LocalPointer(T *p=NULL)
Constructor takes ownership.
LocalPointer< T > & moveFrom(LocalPointer< T > &src) U_NOEXCEPT
Move assignment, leaves src with isNull().
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
friend void swap(LocalPointer< T > &p1, LocalPointer< T > &p2) U_NOEXCEPT
Non-member LocalPointer swap function.
T * orphan()
Gives up ownership; the internal pointer becomes NULL.
LocalPointerBase(T *p=NULL)
Constructor takes ownership.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
friend void swap(LocalArray< T > &p1, LocalArray< T > &p2) U_NOEXCEPT
Non-member LocalArray swap function.
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
"Smart pointer" class, deletes objects via the C++ array delete[] operator.
~LocalPointer()
Destructor deletes the object it owns.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
void adoptInstead(T *p)
Deletes the array it owns, and adopts (takes ownership of) the one passed in.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
void swap(LocalArray< T > &other) U_NOEXCEPT
Swap pointers.
bool operator!=(const T *other) const
Comparison with a simple pointer, so that existing code with !=NULL need not be changed.
~LocalArray()
Destructor deletes the array it owns.
void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode)
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
~LocalPointerBase()
Destructor deletes the object it owns.
Basic definitions for ICU, for both C and C++ APIs.
LocalArray< T > & moveFrom(LocalArray< T > &src) U_NOEXCEPT
Move assignment, leaves src with isNull().
UBool isValid() const
NULL check.
void adoptInstead(T *p)
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
T & operator[](ptrdiff_t i) const
Array item access (writable).
int8_t UBool
The ICU boolean type.