ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Namespaces | Macros | Typedefs
uobject.h File Reference

C++ API: Common ICU base class UObject. More...

`#include "unicode/utypes.h"`

Go to the source code of this file.

## Data Structures
class | icu::UMemory
| UMemory is the common ICU base class. More...
class | icu::UObject
| UObject is the common ICU "boilerplate" class. More...

## Namespaces
| icu
| File coll.h.

## Macros
#define | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass)
| This is a simple macro to add ICU RTTI to an ICU object implementation. More...
#define | UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass)
| This macro adds ICU RTTI to an ICU abstract class implementation. More...

## Typedefs
typedef void * | UClassID
| UClassID is used to identify classes without using the compiler's RTTI. More...

## Detailed Description

C++ API: Common ICU base class UObject.

Definition in file uobject.h.

## Macro Definition Documentation

#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION | ( |  | myClass | ) |

Value:
UClassID U_EXPORT2 myClass::getStaticClassID() { \
static char classID = 0; \
return (UClassID)&classID; \
}
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93

This macro adds ICU RTTI to an ICU abstract class implementation.

This macro should be invoked in *.cpp files. The corresponding header should declare getStaticClassID.

Parameters

  myClass | The name of the class that needs RTTI defined.

Internal:
  Do not use. This API is for internal use only.

Definition at line 312 of file uobject.h.

#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION | ( |  | myClass | ) |

Value:
UClassID U_EXPORT2 myClass::getStaticClassID() { \
static char classID = 0; \
return (UClassID)&classID; \
} \
UClassID myClass::getDynamicClassID() const \
{ return myClass::getStaticClassID(); }
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93

This is a simple macro to add ICU RTTI to an ICU object implementation.

This does not go into the header. This should only be used in *.cpp files.

Parameters

  myClass | The name of the class that needs RTTI defined.

Internal:
  Do not use. This API is for internal use only.

Definition at line 295 of file uobject.h.

## Typedef Documentation

typedef void* UClassID

UClassID is used to identify classes without using the compiler's RTTI.

This was used before C++ compilers consistently supported RTTI. ICU 4.6 requires compiler RTTI to be turned on.

Each class hierarchy which needs to implement polymorphic clone() or operator==() defines two methods, described in detail below. UClassID values can be compared using operator==(). Nothing else should be done with them.

  In class hierarchies that implement "poor man's RTTI", each concrete subclass implements getDynamicClassID() in the same way:

1 class Derived {
2 public:
3 virtual UClassID getDynamicClassID() const
4 { return Derived::getStaticClassID(); }
5 }

Each concrete class implements getStaticClassID() as well, which allows clients to test for a specific type.

1 class Derived {
2 public:
3 static UClassID U_EXPORT2 getStaticClassID();
4 private:
5 static char fgClassID;
6 }
7
8 // In Derived.cpp:
9 UClassID Derived::getStaticClassID()
10 { return (UClassID)&Derived::fgClassID; }
11 char Derived::fgClassID = 0; // Value is irrelevant

Stable:
  ICU 2.0

Definition at line 93 of file uobject.h.