1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 4 ****************************************************************************** 6 * Copyright (C) 2002-2012, International Business Machines 7 * Corporation and others. All Rights Reserved. 9 ****************************************************************************** 10 * file name: uobject.h 12 * tab size: 8 (not used) 15 * created on: 2002jun26 16 * created by: Markus W. Scherer 24 #if U_SHOW_CPLUSPLUS_API 49 #define U_NO_THROW noexcept 52 /*===========================================================================*/ 53 /* UClassID-based RTTI */ 54 /*===========================================================================*/ 118 /* test versions for debugging shaper heap memory problems */ 119 #ifdef SHAPER_MEMORY_DEBUG 120 staticvoid * NewArray(
int size,
int count);
121 staticvoid * GrowArray(
void * array,
int newSize );
122 staticvoid FreeArray(
void * array );
125 #if U_OVERRIDE_CXX_ALLOCATION 134 staticvoid * U_EXPORT2
operatornew(
size_t size) noexcept;
141 staticvoid * U_EXPORT2
operatornew[](
size_t size) noexcept;
151 staticvoid U_EXPORT2
operatordelete(
void *p) noexcept;
158 staticvoid U_EXPORT2
operatordelete[](
void *p) noexcept;
160 #if U_HAVE_PLACEMENT_NEW 166 staticinlinevoid * U_EXPORT2
operatornew(size_t,
void *ptr) noexcept {
return ptr; }
173 staticinlinevoid U_EXPORT2
operatordelete(
void *,
void *) noexcept {}
174 #endif/* U_HAVE_PLACEMENT_NEW */ 175 #if U_HAVE_DEBUG_LOCATION_NEW 183 staticvoid * U_EXPORT2
operatornew(
size_t size,
constchar* file,
int line) noexcept;
191 staticvoid U_EXPORT2
operatordelete(
void* p,
constchar* file,
int line) noexcept;
192 #endif/* U_HAVE_DEBUG_LOCATION_NEW */ 193 #endif/* U_OVERRIDE_CXX_ALLOCATION */ 196 * Assignment operator not declared. The compiler will provide one 197 * which does nothing since this class does not contain any data members. 198 * API/code coverage may show the assignment operator as present and 200 * Subclasses need this assignment operator if they use compiler-provided 201 * assignment operators of their own. An alternative to not declaring one 202 * here would be to declare and empty-implement a protected or public one. 203 UMemory &UMemory::operator=(const UMemory &); 244 // the following functions are protected to prevent instantiation and 245 // direct use of UObject itself 247 // default constructor 248 // inline UObject() {} 251 // inline UObject(const UObject &other) {} 254 // TODO Sometime in the future. Implement operator==(). 255 // (This comment inserted in 2.2) 256 // some or all of the following "boilerplate" functions may be made public 257 // in a future ICU4C release when all subclasses implement them 259 // assignment operator 260 // (not virtual, see "Taligent's Guide to Designing Programs" pp.73..74) 261 // commented out because the implementation is the same as a compiler's default 262 // UObject &operator=(const UObject &other) { return *this; } 264 // comparison operators 268 // clone() commented out from the base class: 269 // some compilers do not support co-variant return types 270 // (i.e., subclasses would have to return UObject * as well, instead of SubClass *) 271 // see also UObject class documentation. 272 // virtual UObject *clone() const; 276 * Assignment operator not declared. The compiler will provide one 277 * which does nothing since this class does not contain any data members. 278 * API/code coverage may show the assignment operator as present and 280 * Subclasses need this assignment operator if they use compiler-provided 281 * assignment operators of their own. An alternative to not declaring one 282 * here would be to declare and empty-implement a protected or public one. 283 UObject &UObject::operator=(const UObject &); 287 #ifndef U_HIDE_INTERNAL_API 295 #define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass) \ 296 UClassID U_EXPORT2 myClass::getStaticClassID() { \ 297 static char classID = 0; \ 298 return (UClassID)&classID; \ 300 UClassID myClass::getDynamicClassID() const \ 301 { return myClass::getStaticClassID(); } 312 #define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass) \ 313 UClassID U_EXPORT2 myClass::getStaticClassID() { \ 314 static char classID = 0; \ 315 return (UClassID)&classID; \ 318 #endif/* U_HIDE_INTERNAL_API */ 322 #endif/* U_SHOW_CPLUSPLUS_API */ UMemory is the common ICU base class.
UObject is the common ICU "boilerplate" class.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
virtual ~UObject()
Destructor.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Basic types for the platform.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.