diff --git a/icu4c/source/common/bidi.cpp b/icu4c/source/common/bidi.cpp index d56c848d9c2..2199dbc1f80 100644 --- a/icu4c/source/common/bidi.cpp +++ b/icu4c/source/common/bidi.cpp @@ -20,3 +20,8 @@ // provide an object for the implementations of the member functions of BiDi #include "unicode/bidi.h" +U_NAMESPACE_BEGIN + +const char BiDi::fgClassID=0; + +U_NAMESPACE_END diff --git a/icu4c/source/common/brkdict.cpp b/icu4c/source/common/brkdict.cpp index b6dfe0c782d..867fa60d583 100644 --- a/icu4c/source/common/brkdict.cpp +++ b/icu4c/source/common/brkdict.cpp @@ -14,6 +14,8 @@ U_NAMESPACE_BEGIN +const char BreakDictionary::fgClassID=0; + //================================================================================= // deserialization //================================================================================= diff --git a/icu4c/source/common/brkdict.h b/icu4c/source/common/brkdict.h index c58ac84b266..92ff3d214c7 100644 --- a/icu4c/source/common/brkdict.h +++ b/icu4c/source/common/brkdict.h @@ -143,6 +143,20 @@ public: */ int16_t at(int32_t row, int32_t col) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Given (logical) row and column numbers, returns true if the @@ -162,6 +176,12 @@ private: // (if you don't declare them, you get default implementations) BreakDictionary(const BreakDictionary& that); BreakDictionary& operator=(const BreakDictionary& that); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/common/charstr.h b/icu4c/source/common/charstr.h index 1ca50827475..6994aa18ca4 100644 --- a/icu4c/source/common/charstr.h +++ b/icu4c/source/common/charstr.h @@ -22,14 +22,35 @@ U_NAMESPACE_BEGIN -class CharString : public UObject { +class U_COMMON_API CharString : public UObject { public: inline CharString(const UnicodeString& str); inline ~CharString(); inline operator const char*() { return ptr; } + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: char buf[128]; char* ptr; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline CharString::CharString(const UnicodeString& str) { diff --git a/icu4c/source/common/common.dsp b/icu4c/source/common/common.dsp index 226c39b2849..fad6f89e500 100644 --- a/icu4c/source/common/common.dsp +++ b/icu4c/source/common/common.dsp @@ -164,6 +164,19 @@ SOURCE=.\brkiter.cpp # Begin Source File SOURCE=.\chariter.cpp + +!IF "$(CFG)" == "common - Win32 Release" + +!ELSEIF "$(CFG)" == "common - Win32 Debug" + +# ADD CPP /W3 + +!ELSEIF "$(CFG)" == "common - Win64 Release" + +!ELSEIF "$(CFG)" == "common - Win64 Debug" + +!ENDIF + # End Source File # Begin Source File @@ -640,6 +653,10 @@ InputPath=.\unicode\chariter.h # End Source File # Begin Source File +SOURCE=.\charstr.h +# End Source File +# Begin Source File + SOURCE=.\cmemory.h # End Source File # Begin Source File diff --git a/icu4c/source/common/convert.cpp b/icu4c/source/common/convert.cpp index 5cae7d15876..d20a38f5ea7 100644 --- a/icu4c/source/common/convert.cpp +++ b/icu4c/source/common/convert.cpp @@ -43,6 +43,9 @@ UBool UnicodeConverter_cleanup() } U_NAMESPACE_BEGIN + +const char UnicodeConverter::fgClassID=0; + UnicodeConverter::UnicodeConverter() { UErrorCode err = U_ZERO_ERROR; diff --git a/icu4c/source/common/dbbi_tbl.cpp b/icu4c/source/common/dbbi_tbl.cpp index 46d9ceab962..5db4f8bf7ca 100644 --- a/icu4c/source/common/dbbi_tbl.cpp +++ b/icu4c/source/common/dbbi_tbl.cpp @@ -15,6 +15,7 @@ U_NAMESPACE_BEGIN +const char DictionaryBasedBreakIteratorTables::fgClassID=0; //======================================================================= // constructor diff --git a/icu4c/source/common/dbbi_tbl.h b/icu4c/source/common/dbbi_tbl.h index 4d74cc47aaa..306a78e5dc8 100644 --- a/icu4c/source/common/dbbi_tbl.h +++ b/icu4c/source/common/dbbi_tbl.h @@ -56,6 +56,20 @@ public: */ virtual ~DictionaryBasedBreakIteratorTables(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * The copy constructor is declared private and not implemented. @@ -76,6 +90,11 @@ private: DictionaryBasedBreakIteratorTables& operator=( const DictionaryBasedBreakIteratorTables& that); + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/common/digitlst.cpp b/icu4c/source/common/digitlst.cpp index c61ac839cd4..11c0aca0aaa 100644 --- a/icu4c/source/common/digitlst.cpp +++ b/icu4c/source/common/digitlst.cpp @@ -54,6 +54,8 @@ enum { U_NAMESPACE_BEGIN +const char DigitList::fgClassID=0; + // ------------------------------------- // default constructor diff --git a/icu4c/source/common/digitlst.h b/icu4c/source/common/digitlst.h index 302cee5e5ef..b8d0e7ace27 100644 --- a/icu4c/source/common/digitlst.h +++ b/icu4c/source/common/digitlst.h @@ -141,6 +141,20 @@ public: // This code is unused. //UBool isLONG_MIN(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + public: /** * These data members are intentionally public and can be set directly. @@ -186,6 +200,12 @@ private: /*static void initializeLONG_MIN_REP(void);*/ UBool shouldRoundUp(int32_t maximumDigits); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // ------------------------------------- diff --git a/icu4c/source/common/hash.h b/icu4c/source/common/hash.h index 09763d85cfb..87beaf81052 100644 --- a/icu4c/source/common/hash.h +++ b/icu4c/source/common/hash.h @@ -24,7 +24,7 @@ U_NAMESPACE_BEGIN * * Hashtable is an INTERNAL CLASS. */ -class Hashtable : public UObject { +class U_COMMON_API Hashtable : public UObject { UHashtable* hash; public: @@ -64,6 +64,28 @@ public: const UHashElement* find(const UnicodeString& key) const; const UHashElement* nextElement(int32_t& pos) const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; /********************************************************************* diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp index 7a111ee718e..8881847e18a 100644 --- a/icu4c/source/common/locid.cpp +++ b/icu4c/source/common/locid.cpp @@ -40,6 +40,8 @@ U_NAMESPACE_BEGIN +const char Locale::fgClassID=0; + static Locale* availableLocaleList = NULL; static int32_t availableLocaleListCount; typedef enum ELocalePos { diff --git a/icu4c/source/common/mutex.cpp b/icu4c/source/common/mutex.cpp index f163c86c2fd..67e8fa4337b 100644 --- a/icu4c/source/common/mutex.cpp +++ b/icu4c/source/common/mutex.cpp @@ -5,6 +5,9 @@ ********************************************************************** */ +#include "unicode/utypes.h" +#include "unicode/uobject.h" +#include "mutex.h" #include "umutex.h" /* Initialize the global mutex only when we can use it. */ @@ -18,4 +21,11 @@ static int GlobalMutexInitialize() static int initializesGlobalMutex = GlobalMutexInitialize(); + +U_NAMESPACE_BEGIN + +const char Mutex::fgClassID=0; + +U_NAMESPACE_END + #endif /* ICU_USE_THREADS==1 */ diff --git a/icu4c/source/common/mutex.h b/icu4c/source/common/mutex.h index ee305af5ad7..54e2da7baeb 100644 --- a/icu4c/source/common/mutex.h +++ b/icu4c/source/common/mutex.h @@ -61,8 +61,28 @@ public: inline Mutex(UMTX *mutex = NULL); inline ~Mutex(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: UMTX *fMutex; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline Mutex::Mutex(UMTX *mutex) @@ -80,11 +100,3 @@ U_NAMESPACE_END #endif //_MUTEX_ //eof - - - - - - - - diff --git a/icu4c/source/common/normlzr.cpp b/icu4c/source/common/normlzr.cpp index 8bd20fa2956..ec9150bde35 100644 --- a/icu4c/source/common/normlzr.cpp +++ b/icu4c/source/common/normlzr.cpp @@ -18,6 +18,8 @@ U_NAMESPACE_BEGIN +const char Normalizer::fgClassID=0; + //------------------------------------------------------------------------- // Constructors and other boilerplate //------------------------------------------------------------------------- diff --git a/icu4c/source/common/rbbidata.cpp b/icu4c/source/common/rbbidata.cpp index 788f04dde48..f75434bfea0 100644 --- a/icu4c/source/common/rbbidata.cpp +++ b/icu4c/source/common/rbbidata.cpp @@ -17,9 +17,7 @@ U_NAMESPACE_BEGIN - - - +const char RBBIDataWrapper::fgClassID=0; //----------------------------------------------------------------------------- // diff --git a/icu4c/source/common/rbbidata.h b/icu4c/source/common/rbbidata.h index 44fb98c10ab..8897544640c 100644 --- a/icu4c/source/common/rbbidata.h +++ b/icu4c/source/common/rbbidata.h @@ -122,12 +122,30 @@ public: UTrie fTrie; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } private: int32_t fRefCount; UDataMemory *fUDataMem; UnicodeString fRuleString; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/common/rbbinode.cpp b/icu4c/source/common/rbbinode.cpp index 4adab0c50c5..f2a5ceb15d3 100644 --- a/icu4c/source/common/rbbinode.cpp +++ b/icu4c/source/common/rbbinode.cpp @@ -31,6 +31,8 @@ U_NAMESPACE_BEGIN +const char RBBINode::fgClassID=0; + int RBBINode::gLastSerial = 0; diff --git a/icu4c/source/common/rbbinode.h b/icu4c/source/common/rbbinode.h index 1fe2a174d8b..24a2886eb1f 100644 --- a/icu4c/source/common/rbbinode.h +++ b/icu4c/source/common/rbbinode.h @@ -91,6 +91,20 @@ class RBBINode : public UObject { void printTree(UBool withHeading=TRUE, UBool doVars=FALSE); static void printUnicodeString(const UnicodeString &s, int minWidth=0); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void operator = (const RBBINode &other); // No defs. UBool operator == (const RBBINode &other); // Private, so these functions won't accidently be used. @@ -98,6 +112,11 @@ class RBBINode : public UObject { int fSerialNum; // Debugging aids. static int gLastSerial; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/common/rbbirb.cpp b/icu4c/source/common/rbbirb.cpp index 9de4492c572..77bdc39378e 100644 --- a/icu4c/source/common/rbbirb.cpp +++ b/icu4c/source/common/rbbirb.cpp @@ -36,7 +36,7 @@ U_NAMESPACE_BEGIN - +const char RBBIRuleBuilder::fgClassID=0; //---------------------------------------------------------------------------------------- // diff --git a/icu4c/source/common/rbbirb.h b/icu4c/source/common/rbbirb.h index c51b209c288..6738565635d 100644 --- a/icu4c/source/common/rbbirb.h +++ b/icu4c/source/common/rbbirb.h @@ -46,6 +46,27 @@ public: // of these structs for each ent UnicodeString key; RBBINode *val; ~RBBISymbolTableEntry(); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; @@ -76,6 +97,28 @@ public: virtual void addEntry (const UnicodeString &key, RBBINode *val, UErrorCode &err); virtual void print() const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; @@ -95,6 +138,19 @@ public: UParseError &parseError, UErrorCode &status); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } public: // The "public" functions and data members that appear below are accessed @@ -125,10 +181,12 @@ public: RBBIDataHeader *flattenData(); // Create the flattened (runtime format) // data tables.. - private: - - + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/common/rbbiscan.cpp b/icu4c/source/common/rbbiscan.cpp index 5350c3e4504..18a68655ff7 100644 --- a/icu4c/source/common/rbbiscan.cpp +++ b/icu4c/source/common/rbbiscan.cpp @@ -37,6 +37,7 @@ U_NAMESPACE_BEGIN +const char RBBIRuleScanner::fgClassID=0; // // Forward Declarations diff --git a/icu4c/source/common/rbbiscan.h b/icu4c/source/common/rbbiscan.h index 6384bb2c30b..77600f06c15 100644 --- a/icu4c/source/common/rbbiscan.h +++ b/icu4c/source/common/rbbiscan.h @@ -73,9 +73,19 @@ public: // trees, one each for the forward and // reverse rules, // and a list of UnicodeSets encountered. + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } - - + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } private: @@ -147,8 +157,13 @@ private: UnicodeSet *gRuleSet_white_space; UnicodeSet *gRuleSet_name_char; UnicodeSet *gRuleSet_name_start_char; - }; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; +}; U_NAMESPACE_END diff --git a/icu4c/source/common/rbbisetb.cpp b/icu4c/source/common/rbbisetb.cpp index 8ecfe456b28..4e56616cbae 100644 --- a/icu4c/source/common/rbbisetb.cpp +++ b/icu4c/source/common/rbbisetb.cpp @@ -41,7 +41,7 @@ U_NAMESPACE_BEGIN - +const char RBBISetBuilder::fgClassID=0; //------------------------------------------------------------------------ // diff --git a/icu4c/source/common/rbbisetb.h b/icu4c/source/common/rbbisetb.h index 56eaa6e3e56..d6f41761c72 100644 --- a/icu4c/source/common/rbbisetb.h +++ b/icu4c/source/common/rbbisetb.h @@ -83,8 +83,23 @@ public: void printRanges(); void printRangeGroups(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } private: + void numberSets(); + RBBIRuleBuilder *fRB; // The RBBI Rule Compiler that owns us. UErrorCode *fStatus; @@ -100,10 +115,11 @@ private: // Index 0 is not used. Funny counting. int32_t fGroupCount; - - -private: - void numberSets(); + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/common/rbbistbl.cpp b/icu4c/source/common/rbbistbl.cpp index 9d5466ab96e..3956af4dd37 100644 --- a/icu4c/source/common/rbbistbl.cpp +++ b/icu4c/source/common/rbbistbl.cpp @@ -23,6 +23,7 @@ U_NAMESPACE_BEGIN +const char RBBISymbolTable::fgClassID=0; // // Forward Declarations @@ -208,6 +209,8 @@ static void U_EXPORT2 U_CALLCONV RBBISymbolTableEntry_deleter(void *p) { }; U_CDECL_END +const char RBBISymbolTableEntry::fgClassID=0; + RBBISymbolTableEntry::~RBBISymbolTableEntry() { // The "val" of a symbol table entry is a variable reference node. // The l. child of the val is the rhs expression from the assignment. diff --git a/icu4c/source/common/rbbitblb.cpp b/icu4c/source/common/rbbitblb.cpp index 31a48d3f22f..e8a071d2ff1 100644 --- a/icu4c/source/common/rbbitblb.cpp +++ b/icu4c/source/common/rbbitblb.cpp @@ -19,6 +19,9 @@ #include #include +U_NAMESPACE_BEGIN + +const char RBBITableBuilder::fgClassID=0; RBBITableBuilder::RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode) : fTree(*rootNode) { @@ -709,6 +712,9 @@ void RBBITableBuilder::printStates() { // Most access is directly to the fields. // //----------------------------------------------------------------------------- + +const char RBBIStateDescriptor::fgClassID=0; + RBBIStateDescriptor::RBBIStateDescriptor(int lastInputSymbol, UErrorCode *fStatus) { fMarked = FALSE; fAccepting = 0; @@ -729,3 +735,5 @@ RBBIStateDescriptor::~RBBIStateDescriptor() { fPositions = NULL; fDtran = NULL; } + +U_NAMESPACE_END diff --git a/icu4c/source/common/rbbitblb.h b/icu4c/source/common/rbbitblb.h index 664369d716e..35b56df11e1 100644 --- a/icu4c/source/common/rbbitblb.h +++ b/icu4c/source/common/rbbitblb.h @@ -46,6 +46,20 @@ public: // TODO: add getter function(s) for the built table. + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void calcNullable(RBBINode *n); void calcFirstPos(RBBINode *n); @@ -77,6 +91,11 @@ private: // Index is state number // Contents are RBBIStateDescriptor pointers. + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // @@ -99,6 +118,28 @@ public: RBBIStateDescriptor(int maxInputSymbol, UErrorCode *fStatus); ~RBBIStateDescriptor(); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/common/resbund.cpp b/icu4c/source/common/resbund.cpp index 2de9f2b7788..44beacf8afb 100644 --- a/icu4c/source/common/resbund.cpp +++ b/icu4c/source/common/resbund.cpp @@ -167,6 +167,8 @@ U_NAMESPACE_BEGIN */ //----------------------------------------------------------------------------- +const char ResourceBundle::fgClassID=0; + ResourceBundle::ResourceBundle( const UnicodeString& path, const Locale& locale, UErrorCode& error) diff --git a/icu4c/source/common/uhash_us.cpp b/icu4c/source/common/uhash_us.cpp index 3e12ffd0fc7..8eb50a9cf8c 100644 --- a/icu4c/source/common/uhash_us.cpp +++ b/icu4c/source/common/uhash_us.cpp @@ -16,6 +16,12 @@ #include "unicode/unistr.h" #include "unicode/uchar.h" +U_NAMESPACE_BEGIN + +const char Hashtable::fgClassID=0; + +U_NAMESPACE_END + /******************************************************************** * PUBLIC UnicodeString support functions for UHashtable ********************************************************************/ diff --git a/icu4c/source/common/unicode/bidi.h b/icu4c/source/common/unicode/bidi.h index eba123b2196..40c63758230 100644 --- a/icu4c/source/common/unicode/bidi.h +++ b/icu4c/source/common/unicode/bidi.h @@ -232,8 +232,30 @@ public: uint16_t options, UErrorCode &rErrorCode); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: UBiDi *pBiDi; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; /* Inline implementations. -------------------------------------------------- */ diff --git a/icu4c/source/common/unicode/convert.h b/icu4c/source/common/unicode/convert.h index bbd15909ff2..d87460dea52 100644 --- a/icu4c/source/common/unicode/convert.h +++ b/icu4c/source/common/unicode/convert.h @@ -419,13 +419,28 @@ void fixFileSeparator(UnicodeString& source) const; */ UBool isAmbiguous(void) const; -}; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } -/** - * Typedef for backward compatibility - * @deprecated Remove in 2.0 release - */ -typedef UnicodeConverter UnicodeConverterCPP; /* Backwards compatibility. */ + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; +}; U_NAMESPACE_END #endif diff --git a/icu4c/source/common/unicode/locid.h b/icu4c/source/common/unicode/locid.h index 27f113af140..f8e29142013 100644 --- a/icu4c/source/common/unicode/locid.h +++ b/icu4c/source/common/unicode/locid.h @@ -673,6 +673,20 @@ public: */ static const char* const* getISOLanguages(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /* only protected for testing purposes. DO NOT USE. */ /** set it from a single string. */ void setFromPOSIXID(const char *posixID); @@ -698,6 +712,12 @@ private: char fullNameBuffer[ULOC_FULLNAME_CAPACITY]; UBool fIsBogus; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; // static Locale *localeList; // static int32_t localeListCount; diff --git a/icu4c/source/common/unicode/normlzr.h b/icu4c/source/common/unicode/normlzr.h index e7d1c7e2722..a982b7a49b3 100644 --- a/icu4c/source/common/unicode/normlzr.h +++ b/icu4c/source/common/unicode/normlzr.h @@ -672,6 +672,20 @@ public: */ void getText(UnicodeString& result); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + //------------------------------------------------------------------------- // Deprecated APIs //------------------------------------------------------------------------- @@ -1044,6 +1058,12 @@ private: // A buffer for holding intermediate results UnicodeString buffer; int32_t bufferPos; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; //------------------------------------------------------------------------- diff --git a/icu4c/source/common/unicode/parsepos.h b/icu4c/source/common/unicode/parsepos.h index 437ef838894..f6d8b215717 100644 --- a/icu4c/source/common/unicode/parsepos.h +++ b/icu4c/source/common/unicode/parsepos.h @@ -120,6 +120,20 @@ public: */ int32_t getErrorIndex(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Input: the place you start parsing. @@ -133,6 +147,12 @@ private: * The index at which a parse error occurred. */ int32_t errorIndex; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline ParsePosition& diff --git a/icu4c/source/common/unicode/resbund.h b/icu4c/source/common/unicode/resbund.h index 56d8ead5210..37130956d97 100644 --- a/icu4c/source/common/unicode/resbund.h +++ b/icu4c/source/common/unicode/resbund.h @@ -474,6 +474,20 @@ public: */ const Locale &getLocale(void) const ; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: UResourceBundle *resource; void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error); @@ -482,6 +496,12 @@ private: */ void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error); Locale *locName; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/common/unicode/unifilt.h b/icu4c/source/common/unicode/unifilt.h index da14e0ff47f..182178d6c8d 100644 --- a/icu4c/source/common/unicode/unifilt.h +++ b/icu4c/source/common/unicode/unifilt.h @@ -95,6 +95,20 @@ public: */ virtual void setData(const TransliterationRuleData*) {} + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + /** * Stubbed out implementation of UnicodeMatcher API. * @param toUnionTo the set into which to union the source characters @@ -105,6 +119,14 @@ public: protected: UnicodeFilter(); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline UnicodeFilter::UnicodeFilter() {} diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index a08f77dde58..857dc25e81b 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -2845,6 +2845,20 @@ public: */ UChar32 unescapeAt(int32_t &offset) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + //======================================== // Implementation methods //======================================== @@ -3088,6 +3102,12 @@ private: uint16_t fPadding; // padding to align the fStackBuffer for UTF-32 #endif UChar fStackBuffer [ US_STACKBUF_SIZE ]; // buffer for small strings + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END @@ -3994,9 +4014,29 @@ public: inline operator UChar(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: UnicodeString *fString; int32_t fPos; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/common/unicode/uobject.h b/icu4c/source/common/unicode/uobject.h index 790a52f35a7..6d7eaee493e 100644 --- a/icu4c/source/common/unicode/uobject.h +++ b/icu4c/source/common/unicode/uobject.h @@ -34,10 +34,20 @@ U_NAMESPACE_BEGIN * C++ memory management by adding new/delete operators to this base class. * ICU itself will not declare and implement these new/delete operators, but * users of ICU can modify the ICU code for the base class. + * + * UObject contains pure virtual methods to allow derived classes like Format + * (which used to be base classes themselves before UObject was introduced) + * to have pure virtual methods. + * + * @draft ICU 2.2 */ class U_COMMON_API UObject { public: - // destructor + /** + * Destructor. + * + * @draft ICU 2.2 + */ virtual inline ~UObject() {} // possible overrides for ICU4C C++ memory management, @@ -51,20 +61,27 @@ public: // void operator delete(void *p, size_t size); // void operator delete[](void *p, size_t size); - // ICU4C "poor man's RTTI" - static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } - virtual inline UClassID getDynamicClassID() { return getStaticClassID(); } + /** + * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const = 0; protected: // the following functions are protected to prevent instantiation and // direct use of UObject itself // default constructor - inline UObject() {} + // commented out because UObject is abstract (see getDynamicClassID) + // inline UObject() {} // copy constructor - inline UObject(const UObject &other) {} + // commented out because UObject is abstract (see getDynamicClassID) + // inline UObject(const UObject &other) {} +#if U_ICU_VERSION_MAJOR_NUM>2 || (U_ICU_VERSION_MAJOR_NUM==2 && U_ICU_VERSION_MINOR_NUM>2) + // TODO post ICU 2.2 // some or all of the following "boilerplate" functions may be made public // in a future ICU4C release when all subclasses implement them @@ -81,10 +98,7 @@ protected: // some compilers do not support co-variant return types // (i.e., subclasses would have to return UObject& as well, instead of SubClass&) // virtual UObject *clone() const; - -private: - // for ICU4C "poor man's RTTI" - static const char fgClassID; +#endif }; U_NAMESPACE_END diff --git a/icu4c/source/common/unicode/usetiter.h b/icu4c/source/common/unicode/usetiter.h index bde5c278979..73120c248c1 100644 --- a/icu4c/source/common/unicode/usetiter.h +++ b/icu4c/source/common/unicode/usetiter.h @@ -4,7 +4,7 @@ * Corporation and others. All Rights Reserved. ********************************************************************** * $Source: /xsrl/Nsvn/icu/icu/source/common/unicode/usetiter.h,v $ -* $Revision: 1.2 $ +* $Revision: 1.3 $ ********************************************************************** */ #ifndef USETITER_H @@ -190,6 +190,20 @@ class U_COMMON_API UnicodeSetIterator : public UObject { */ void reset(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + // ======================= PRIVATES =========================== protected: @@ -211,6 +225,14 @@ class U_COMMON_API UnicodeSetIterator : public UObject { UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow virtual void loadRange(int32_t range); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline UBool UnicodeSetIterator::isString() const { diff --git a/icu4c/source/common/unifilt.cpp b/icu4c/source/common/unifilt.cpp index 192453b1d9c..a8101b0c2a0 100644 --- a/icu4c/source/common/unifilt.cpp +++ b/icu4c/source/common/unifilt.cpp @@ -11,6 +11,8 @@ U_NAMESPACE_BEGIN +const char UnicodeFilter::fgClassID=0; + /** * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer * and return the pointer. diff --git a/icu4c/source/common/uniset.cpp b/icu4c/source/common/uniset.cpp index 910d5d9812a..816402e3787 100644 --- a/icu4c/source/common/uniset.cpp +++ b/icu4c/source/common/uniset.cpp @@ -89,6 +89,8 @@ static const UChar CATEGORY_CLOSE[] = {COLON, SET_CLOSE, 0x0000}; /* ":]" */ U_NAMESPACE_BEGIN +const char ParsePosition::fgClassID=0; + /** * Minimum value that can be stored in a UnicodeSet. */ diff --git a/icu4c/source/common/unistr.cpp b/icu4c/source/common/unistr.cpp index 6d3df977367..f67ea5b2f7e 100644 --- a/icu4c/source/common/unistr.cpp +++ b/icu4c/source/common/unistr.cpp @@ -93,6 +93,8 @@ us_arrayCopy(const UChar *src, int32_t srcStart, U_NAMESPACE_BEGIN +const char UnicodeString::fgClassID=0; +const char UCharReference::fgClassID=0; //======================================== // Reference Counting functions, put at top of file so that optimizing compilers diff --git a/icu4c/source/common/uobject.cpp b/icu4c/source/common/uobject.cpp index 37ec90a3036..20dbcb780db 100644 --- a/icu4c/source/common/uobject.cpp +++ b/icu4c/source/common/uobject.cpp @@ -19,6 +19,4 @@ U_NAMESPACE_BEGIN -const char UObject::fgClassID=0; - U_NAMESPACE_END diff --git a/icu4c/source/common/upropset.cpp b/icu4c/source/common/upropset.cpp index c9cd090a717..5477cf92263 100644 --- a/icu4c/source/common/upropset.cpp +++ b/icu4c/source/common/upropset.cpp @@ -147,6 +147,8 @@ U_CFUNC UBool upropset_cleanup(void) { U_NAMESPACE_BEGIN +const char CharString::fgClassID=0; + //---------------------------------------------------------------- // Public API //---------------------------------------------------------------- diff --git a/icu4c/source/common/upropset.h b/icu4c/source/common/upropset.h index c3c439e214d..a82fd6fb374 100644 --- a/icu4c/source/common/upropset.h +++ b/icu4c/source/common/upropset.h @@ -59,7 +59,7 @@ class Hashtable; * @author Alan Liu * @internal */ -class UnicodePropertySet : public UObject { +class UnicodePropertySet /* not : public UObject because all methods are static */ { public: @@ -226,6 +226,9 @@ class UnicodePropertySet : public UObject { static void init(); private: + // do not instantiate + UnicodePropertySet(); + //---------------------------------------------------------------- // SetFactory <=> void* // I don't know why the compiler won't cast between these types. diff --git a/icu4c/source/common/uset.cpp b/icu4c/source/common/uset.cpp index 130fd56edda..1ca4d201f9e 100644 --- a/icu4c/source/common/uset.cpp +++ b/icu4c/source/common/uset.cpp @@ -118,7 +118,7 @@ U_NAMESPACE_BEGIN * USet support API. Declaring a class a friend is more portable than * trying to declare extern "C" functions as friends. */ -class USetAccess : public UObject { +class USetAccess /* not : public UObject because all methods are static */ { public: // Try to have the compiler inline these inline static int32_t getStringCount(const UnicodeSet& set) { @@ -128,6 +128,9 @@ public: int32_t i) { return set.getString(i); } +private: + // do not instantiate + USetAccess(); }; U_NAMESPACE_END diff --git a/icu4c/source/common/usetiter.cpp b/icu4c/source/common/usetiter.cpp index f85693419d3..522e0ffe966 100644 --- a/icu4c/source/common/usetiter.cpp +++ b/icu4c/source/common/usetiter.cpp @@ -4,8 +4,8 @@ * Corporation and others. All Rights Reserved. ********************************************************************** * $Source: /xsrl/Nsvn/icu/icu/source/common/usetiter.cpp,v $ -* $Date: 2002/06/01 06:36:02 $ -* $Revision: 1.2 $ +* $Date: 2002/06/28 23:53:51 $ +* $Revision: 1.3 $ ********************************************************************** */ #include "unicode/usetiter.h" @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char UnicodeSetIterator::fgClassID=0; + /** * Create an iterator * @param set set to iterate over diff --git a/icu4c/source/common/util.h b/icu4c/source/common/util.h index 8f69e96aebb..5a29da69024 100644 --- a/icu4c/source/common/util.h +++ b/icu4c/source/common/util.h @@ -23,7 +23,7 @@ U_NAMESPACE_BEGIN class UnicodeMatcher; -class U_COMMON_API ICU_Utility : public UObject { +class U_COMMON_API ICU_Utility /* not : public UObject because all methods are static */ { public: /** @@ -183,6 +183,10 @@ class U_COMMON_API ICU_Utility : public UObject { const UnicodeMatcher* matcher, UBool escapeUnprintable, UnicodeString& quoteBuf); + +private: + // do not instantiate + ICU_Utility(); }; U_NAMESPACE_END diff --git a/icu4c/source/common/uvector.cpp b/icu4c/source/common/uvector.cpp index f1f531c79f1..87a3e13da76 100644 --- a/icu4c/source/common/uvector.cpp +++ b/icu4c/source/common/uvector.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN #define DEFUALT_CAPACITY 8 +const char UVector::fgClassID=0; + UVector::UVector(UErrorCode &status) : count(0), capacity(0), @@ -433,6 +435,8 @@ void UVector::sortedInsert(UHashTok tok, USortComparator compare, UErrorCode& ec } } +const char UStack::fgClassID=0; + UStack::UStack(UErrorCode &status) : UVector(status) { diff --git a/icu4c/source/common/uvector.h b/icu4c/source/common/uvector.h index a91a191ba22..69ce18ce759 100644 --- a/icu4c/source/common/uvector.h +++ b/icu4c/source/common/uvector.h @@ -243,6 +243,20 @@ public: */ void sortedInsert(int32_t obj, USortComparator compare, UErrorCode& ec); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void _init(int32_t initialCapacity, UErrorCode &status); @@ -255,6 +269,12 @@ private: // Disallow UVector& operator=(const UVector&); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; @@ -303,12 +323,32 @@ public: int32_t search(void* obj) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: // Disallow UStack(const UStack&); // Disallow UStack& operator=(const UStack&); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/extra/scrptrun/scrptrun.cpp b/icu4c/source/extra/scrptrun/scrptrun.cpp index a0264a094e6..8d9865155af 100644 --- a/icu4c/source/extra/scrptrun/scrptrun.cpp +++ b/icu4c/source/extra/scrptrun/scrptrun.cpp @@ -18,6 +18,8 @@ #define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) +const char ScriptRun::fgClassID=0; + UChar32 ScriptRun::pairedChars[] = { 0x0028, 0x0029, // ascii paired punctuation 0x003c, 0x003e, diff --git a/icu4c/source/extra/scrptrun/scrptrun.h b/icu4c/source/extra/scrptrun/scrptrun.h index 3e37b0bc572..5ceddd77e54 100644 --- a/icu4c/source/extra/scrptrun/scrptrun.h +++ b/icu4c/source/extra/scrptrun/scrptrun.h @@ -53,6 +53,20 @@ public: UBool next(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: static UBool sameScript(int32_t scriptOne, int32_t scriptTwo); @@ -75,6 +89,12 @@ private: static const int32_t pairedCharCount; static const int32_t pairedCharPower; static const int32_t pairedCharExtra; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline ScriptRun::ScriptRun() diff --git a/icu4c/source/extra/ustdio/ustream.cpp b/icu4c/source/extra/ustdio/ustream.cpp index 04bb5654c8f..1eb4fb3448d 100644 --- a/icu4c/source/extra/ustdio/ustream.cpp +++ b/icu4c/source/extra/ustdio/ustream.cpp @@ -133,7 +133,7 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) #endif #if 0 -/* UnicodeStringStreamer insternal API may be useful for future reference */ +/* UnicodeStringStreamer internal API may be useful for future reference */ #ifndef UNISTRM_H #define UNISTRM_H @@ -142,7 +142,7 @@ operator>>(STD_ISTREAM& stream, UnicodeString& str) #include "unicode/unistr.h" -class U_COMMON_API UnicodeStringStreamer : public UObject { +class U_COMMON_API UnicodeStringStreamer /* not : public UObject because all methods are static */ { public: static void streamIn(UnicodeString* string, FileStream* is); static void streamOut(const UnicodeString* string, FileStream* os); diff --git a/icu4c/source/i18n/anytrans.cpp b/icu4c/source/i18n/anytrans.cpp index cfb2d812a8d..4ce4e90d832 100644 --- a/icu4c/source/i18n/anytrans.cpp +++ b/icu4c/source/i18n/anytrans.cpp @@ -4,7 +4,7 @@ * and others. All Rights Reserved. ***************************************************************** * $Source: /xsrl/Nsvn/icu/icu/source/i18n/anytrans.cpp,v $ -* $Revision: 1.6 $ +* $Revision: 1.7 $ ***************************************************************** * Date Name Description * 06/06/2002 aliu Creation. @@ -102,8 +102,32 @@ public: * given delta. A positive delta means the limit has increased. */ void adjustLimit(int32_t delta); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char ScriptRunIterator::fgClassID=0; + ScriptRunIterator::ScriptRunIterator(const Replaceable& theText, int32_t start, int32_t limit) : text(theText) { @@ -165,6 +189,8 @@ void ScriptRunIterator::adjustLimit(int32_t delta) { //------------------------------------------------------------ // AnyTransliterator +const char AnyTransliterator::fgClassID=0; + AnyTransliterator::AnyTransliterator(const UnicodeString& id, const UnicodeString& theTarget, const UnicodeString& theVariant, diff --git a/icu4c/source/i18n/anytrans.h b/icu4c/source/i18n/anytrans.h index 53e820cd628..04c670af23d 100644 --- a/icu4c/source/i18n/anytrans.h +++ b/icu4c/source/i18n/anytrans.h @@ -4,7 +4,7 @@ * and others. All Rights Reserved. ***************************************************************** * $Source: /xsrl/Nsvn/icu/icu/source/i18n/anytrans.h,v $ -* $Revision: 1.2 $ +* $Revision: 1.3 $ ***************************************************************** * Date Name Description * 06/06/2002 aliu Creation. @@ -48,6 +48,12 @@ class U_I18N_API AnyTransliterator : public Transliterator { */ UScriptCode targetScript; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -71,6 +77,20 @@ public: virtual void handleTransliterate(Replaceable& text, UTransPosition& index, UBool incremental) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** diff --git a/icu4c/source/i18n/caniter.cpp b/icu4c/source/i18n/caniter.cpp index 77b89cb7c99..61329ccb635 100644 --- a/icu4c/source/i18n/caniter.cpp +++ b/icu4c/source/i18n/caniter.cpp @@ -70,8 +70,12 @@ static const UnicodeString &Tr(const UnicodeString &source) { #endif // public +U_NAMESPACE_BEGIN + // TODO: add boilerplate methods. +const char CanonicalIterator::fgClassID=0; + /** *@param source string to get results for */ @@ -529,4 +533,4 @@ Hashtable *CanonicalIterator::extract(UChar32 comp, const UChar *segment, int32_ return getEquivalents2(buff, bufLen, status); } - +U_NAMESPACE_END diff --git a/icu4c/source/i18n/caniter.h b/icu4c/source/i18n/caniter.h index 04d17bdead6..6e16464dcaa 100644 --- a/icu4c/source/i18n/caniter.h +++ b/icu4c/source/i18n/caniter.h @@ -96,6 +96,20 @@ public: */ static void permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: // ===================== PRIVATES ============================== @@ -133,6 +147,12 @@ private: //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status); void cleanPieces(); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END #endif diff --git a/icu4c/source/i18n/coleitr.cpp b/icu4c/source/i18n/coleitr.cpp index 3f75a205316..948d4abd348 100644 --- a/icu4c/source/i18n/coleitr.cpp +++ b/icu4c/source/i18n/coleitr.cpp @@ -34,6 +34,8 @@ U_NAMESPACE_BEGIN +const char CollationElementIterator::fgClassID=0; + /* synwee : public can't remove */ int32_t const CollationElementIterator::NULLORDER = 0xffffffff; diff --git a/icu4c/source/i18n/cpdtrans.cpp b/icu4c/source/i18n/cpdtrans.cpp index dd6bb27c02f..1fa27e55cf2 100644 --- a/icu4c/source/i18n/cpdtrans.cpp +++ b/icu4c/source/i18n/cpdtrans.cpp @@ -24,6 +24,8 @@ static const UChar EMPTY[] = {0}; //"" U_NAMESPACE_BEGIN +const char CompoundTransliterator::fgClassID=0; + /** * Constructs a new compound transliterator given an array of * transliterators. The array of transliterators may be of any diff --git a/icu4c/source/i18n/dcfmtsym.cpp b/icu4c/source/i18n/dcfmtsym.cpp index 7ce4c198d36..8757267cf5f 100644 --- a/icu4c/source/i18n/dcfmtsym.cpp +++ b/icu4c/source/i18n/dcfmtsym.cpp @@ -27,6 +27,8 @@ U_NAMESPACE_BEGIN +const char DecimalFormatSymbols::fgClassID=0; + const char DecimalFormatSymbols::fgNumberElements[] = "NumberElements"; const char DecimalFormatSymbols::fgCurrencyElements[] = "CurrencyElements"; diff --git a/icu4c/source/i18n/digitlst.cpp b/icu4c/source/i18n/digitlst.cpp index c61ac839cd4..11c0aca0aaa 100644 --- a/icu4c/source/i18n/digitlst.cpp +++ b/icu4c/source/i18n/digitlst.cpp @@ -54,6 +54,8 @@ enum { U_NAMESPACE_BEGIN +const char DigitList::fgClassID=0; + // ------------------------------------- // default constructor diff --git a/icu4c/source/i18n/digitlst.h b/icu4c/source/i18n/digitlst.h index 302cee5e5ef..b8d0e7ace27 100644 --- a/icu4c/source/i18n/digitlst.h +++ b/icu4c/source/i18n/digitlst.h @@ -141,6 +141,20 @@ public: // This code is unused. //UBool isLONG_MIN(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + public: /** * These data members are intentionally public and can be set directly. @@ -186,6 +200,12 @@ private: /*static void initializeLONG_MIN_REP(void);*/ UBool shouldRoundUp(int32_t maximumDigits); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // ------------------------------------- diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 68349c0191f..8e76c2f3be0 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -114,6 +114,8 @@ U_CFUNC UBool dateFormatSymbols_cleanup() { U_NAMESPACE_BEGIN +const char DateFormatSymbols::fgClassID=0; + /** * These are the tags we expect to see in normal resource bundle files associated * with a locale. diff --git a/icu4c/source/i18n/esctrn.cpp b/icu4c/source/i18n/esctrn.cpp index 6906fbd3081..5f8fa1a9694 100644 --- a/icu4c/source/i18n/esctrn.cpp +++ b/icu4c/source/i18n/esctrn.cpp @@ -23,6 +23,8 @@ static const UChar SEMI[] = {59,0}; // ";" static const UChar RBRACE[] = {125,0}; // "}" static const UChar EMPTY[] = {0}; // "" +const char EscapeTransliterator::fgClassID=0; + /** * Factory methods */ diff --git a/icu4c/source/i18n/esctrn.h b/icu4c/source/i18n/esctrn.h index 651000d4483..80a9de7fc0b 100644 --- a/icu4c/source/i18n/esctrn.h +++ b/icu4c/source/i18n/esctrn.h @@ -78,6 +78,12 @@ class U_I18N_API EscapeTransliterator : public Transliterator { */ EscapeTransliterator* supplementalHandler; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -111,6 +117,20 @@ class U_I18N_API EscapeTransliterator : public Transliterator { */ virtual Transliterator* clone() const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** diff --git a/icu4c/source/i18n/fmtable.cpp b/icu4c/source/i18n/fmtable.cpp index ba122d380f8..bfc266f7b35 100644 --- a/icu4c/source/i18n/fmtable.cpp +++ b/icu4c/source/i18n/fmtable.cpp @@ -21,6 +21,8 @@ U_NAMESPACE_BEGIN +const char Formattable::fgClassID=0; + // ------------------------------------- // default constructor. // Creates a formattable object with a long value 0. diff --git a/icu4c/source/i18n/format.cpp b/icu4c/source/i18n/format.cpp index 65a2560e7f4..e453b4402a0 100644 --- a/icu4c/source/i18n/format.cpp +++ b/icu4c/source/i18n/format.cpp @@ -27,6 +27,7 @@ U_NAMESPACE_BEGIN +const char FieldPosition::fgClassID=0; // ------------------------------------- // default constructor diff --git a/icu4c/source/i18n/funcrepl.cpp b/icu4c/source/i18n/funcrepl.cpp index aa9f14c8887..3a13e368e66 100644 --- a/icu4c/source/i18n/funcrepl.cpp +++ b/icu4c/source/i18n/funcrepl.cpp @@ -17,6 +17,8 @@ static const UChar CLOSE[] = {32,41,0}; // " )" U_NAMESPACE_BEGIN +const char FunctionReplacer::fgClassID=0; + /** * Construct a replacer that takes the output of the given * replacer, passes it through the given transliterator, and emits diff --git a/icu4c/source/i18n/funcrepl.h b/icu4c/source/i18n/funcrepl.h index f64d3b184ec..25f03f85750 100644 --- a/icu4c/source/i18n/funcrepl.h +++ b/icu4c/source/i18n/funcrepl.h @@ -36,6 +36,12 @@ class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { */ UnicodeFunctor* replacer; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -90,6 +96,20 @@ class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { * UnicodeFunctor API */ virtual void setData(const TransliterationRuleData*); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/hextouni.cpp b/icu4c/source/i18n/hextouni.cpp index 89f0eb4bd67..3ba2b9f226d 100644 --- a/icu4c/source/i18n/hextouni.cpp +++ b/icu4c/source/i18n/hextouni.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char HexToUnicodeTransliterator::fgClassID=0; + /** * ID for this transliterator. */ diff --git a/icu4c/source/i18n/name2uni.cpp b/icu4c/source/i18n/name2uni.cpp index 6998c53fdf5..455aafcfc57 100644 --- a/icu4c/source/i18n/name2uni.cpp +++ b/icu4c/source/i18n/name2uni.cpp @@ -17,6 +17,8 @@ U_NAMESPACE_BEGIN +const char NameUnicodeTransliterator::fgClassID=0; + const char NameUnicodeTransliterator::_ID[] = "Name-Any"; /** diff --git a/icu4c/source/i18n/name2uni.h b/icu4c/source/i18n/name2uni.h index ad26354d88e..4e73101e8b9 100644 --- a/icu4c/source/i18n/name2uni.h +++ b/icu4c/source/i18n/name2uni.h @@ -24,6 +24,12 @@ class U_I18N_API NameUnicodeTransliterator : public Transliterator { UChar32 openDelimiter; UChar32 closeDelimiter; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -64,6 +70,20 @@ class U_I18N_API NameUnicodeTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** diff --git a/icu4c/source/i18n/nfrlist.h b/icu4c/source/i18n/nfrlist.h index 79d26aedb43..b108897501e 100644 --- a/icu4c/source/i18n/nfrlist.h +++ b/icu4c/source/i18n/nfrlist.h @@ -71,6 +71,28 @@ public: fCapacity = 0; return result; } + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/nfrs.cpp b/icu4c/source/i18n/nfrs.cpp index 5f188361740..6adaca601c8 100644 --- a/icu4c/source/i18n/nfrs.cpp +++ b/icu4c/source/i18n/nfrs.cpp @@ -112,6 +112,8 @@ static const UChar gPercentPercent[] = 0x25, 0x25, 0 }; /* "%%" */ +const char NFRuleSet::fgClassID=0; + NFRuleSet::NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status) : name() , rules(0) diff --git a/icu4c/source/i18n/nfrs.h b/icu4c/source/i18n/nfrs.h index 01e9c72232d..a10b4e43085 100644 --- a/icu4c/source/i18n/nfrs.h +++ b/icu4c/source/i18n/nfrs.h @@ -53,6 +53,20 @@ class NFRuleSet : public UObject { void appendRules(UnicodeString& result) const; // toString + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: NFRule * findNormalRule(int64_t number) const; NFRule * findDoubleRule(double number) const; @@ -65,6 +79,12 @@ class NFRuleSet : public UObject { NFRule *fractionRules[3]; UBool fIsFractionRuleSet; UBool fIsPublic; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // utilities from old llong.h diff --git a/icu4c/source/i18n/nfrule.cpp b/icu4c/source/i18n/nfrule.cpp index f571a4a8c36..86803575008 100644 --- a/icu4c/source/i18n/nfrule.cpp +++ b/icu4c/source/i18n/nfrule.cpp @@ -30,6 +30,9 @@ U_NAMESPACE_BEGIN extern const UChar* CSleftBracket; extern const UChar* CSrightBracket; +const char NFRuleList::fgClassID=0; +const char NFRule::fgClassID=0; + NFRule::NFRule(const RuleBasedNumberFormat* _rbnf) : baseValue((int32_t)0) , radix(0) diff --git a/icu4c/source/i18n/nfrule.h b/icu4c/source/i18n/nfrule.h index 3cc43aba3c9..59fae91805f 100644 --- a/icu4c/source/i18n/nfrule.h +++ b/icu4c/source/i18n/nfrule.h @@ -72,6 +72,20 @@ public: void appendRuleText(UnicodeString& result) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void parseRuleDescriptor(UnicodeString& descriptor, UErrorCode& status); void extractSubstitutions(const NFRuleSet* ruleSet, const NFRule* predecessor, const RuleBasedNumberFormat* rbnf, UErrorCode& status); @@ -97,6 +111,12 @@ private: NFSubstitution* sub1; NFSubstitution* sub2; const RuleBasedNumberFormat* formatter; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/nortrans.cpp b/icu4c/source/i18n/nortrans.cpp index fa09d7767df..0686b6856d3 100644 --- a/icu4c/source/i18n/nortrans.cpp +++ b/icu4c/source/i18n/nortrans.cpp @@ -30,6 +30,8 @@ static UnicodeSet* SKIPPABLES = NULL; static const int32_t D = 0, C = 1, KD= 2, KC = 3; +const char NormalizationTransliterator::fgClassID=0; + /** * System registration hook. */ diff --git a/icu4c/source/i18n/nortrans.h b/icu4c/source/i18n/nortrans.h index 3da1017a02e..76d122c5761 100644 --- a/icu4c/source/i18n/nortrans.h +++ b/icu4c/source/i18n/nortrans.h @@ -37,6 +37,12 @@ class U_I18N_API NormalizationTransliterator : public Transliterator { */ UnicodeSet* skippable; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -59,6 +65,20 @@ class U_I18N_API NormalizationTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** diff --git a/icu4c/source/i18n/nultrans.cpp b/icu4c/source/i18n/nultrans.cpp index 50fe4da6925..fa4d130f23d 100644 --- a/icu4c/source/i18n/nultrans.cpp +++ b/icu4c/source/i18n/nultrans.cpp @@ -11,6 +11,7 @@ U_NAMESPACE_BEGIN +const char NullTransliterator::fgClassID=0; // "Any-Null" const UChar NullTransliterator::ID[] = {65,110,121,45,0x4E, 0x75, 0x6C, 0x6C, 0x00}; diff --git a/icu4c/source/i18n/quant.cpp b/icu4c/source/i18n/quant.cpp index 7d936380c92..bc38f8161c1 100644 --- a/icu4c/source/i18n/quant.cpp +++ b/icu4c/source/i18n/quant.cpp @@ -12,6 +12,8 @@ U_NAMESPACE_BEGIN +const char Quantifier::fgClassID=0; + Quantifier::Quantifier(UnicodeFunctor *adoptedMatcher, uint32_t _minCount, uint32_t _maxCount) { // assert(adopted != 0); diff --git a/icu4c/source/i18n/quant.h b/icu4c/source/i18n/quant.h index cb50e4df871..a7e9fd484ef 100644 --- a/icu4c/source/i18n/quant.h +++ b/icu4c/source/i18n/quant.h @@ -66,6 +66,20 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher { */ virtual void setData(const TransliterationRuleData*); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: static void appendNumber(UnicodeString& result, int32_t n); @@ -75,6 +89,12 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher { uint32_t minCount; uint32_t maxCount; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/rbt_data.cpp b/icu4c/source/i18n/rbt_data.cpp index fc9ac0899dc..54d9f6a7a5f 100644 --- a/icu4c/source/i18n/rbt_data.cpp +++ b/icu4c/source/i18n/rbt_data.cpp @@ -14,6 +14,8 @@ U_NAMESPACE_BEGIN +const char TransliterationRuleData::fgClassID=0; + TransliterationRuleData::TransliterationRuleData(UErrorCode& status) : ruleSet(status), variableNames(0), variables(0) diff --git a/icu4c/source/i18n/rbt_data.h b/icu4c/source/i18n/rbt_data.h index fc7c89b0785..e5a0680b555 100644 --- a/icu4c/source/i18n/rbt_data.h +++ b/icu4c/source/i18n/rbt_data.h @@ -109,6 +109,28 @@ public: * represents something that is not a replacer. */ UnicodeReplacer* lookupReplacer(UChar32 standIn) const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/rbt_pars.cpp b/icu4c/source/i18n/rbt_pars.cpp index 0ccd683b268..5626257f1f4 100644 --- a/icu4c/source/i18n/rbt_pars.cpp +++ b/icu4c/source/i18n/rbt_pars.cpp @@ -127,8 +127,32 @@ public: * character (non standin). */ UBool isReplacer(UChar32 ch); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char ParseData::fgClassID=0; + ParseData::ParseData(const TransliterationRuleData* d, const UVector* sets) : data(d), variablesVector(sets) {} @@ -289,12 +313,34 @@ public: return parser.syntaxError(code, rule, start); } + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: // Disallowed methods; no impl. RuleHalf(const RuleHalf&); RuleHalf& operator=(const RuleHalf&); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char RuleHalf::fgClassID=0; + RuleHalf::RuleHalf(TransliteratorParser& p) : ec(U_ZERO_ERROR), parser(p) @@ -766,6 +812,8 @@ UBool RuleHalf::isValidInput(TransliteratorParser& transParser) { // PUBLIC API //---------------------------------------------------------------------- +const char TransliteratorParser::fgClassID=0; + /** * Constructor. */ diff --git a/icu4c/source/i18n/rbt_pars.h b/icu4c/source/i18n/rbt_pars.h index 7563f2027ad..61b392dea20 100644 --- a/icu4c/source/i18n/rbt_pars.h +++ b/icu4c/source/i18n/rbt_pars.h @@ -172,6 +172,20 @@ public: */ TransliterationRuleData* orphanData(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void parseRules(const UnicodeString& rules, @@ -293,6 +307,12 @@ private: // Disallowed methods; no impl. TransliteratorParser(const TransliteratorParser&); TransliteratorParser& operator=(const TransliteratorParser&); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/rbt_rule.cpp b/icu4c/source/i18n/rbt_rule.cpp index 102b41ea99a..b905de9ceb8 100644 --- a/icu4c/source/i18n/rbt_rule.cpp +++ b/icu4c/source/i18n/rbt_rule.cpp @@ -21,6 +21,8 @@ static const UChar FORWARD_OP[] = {32,62,32,0}; // " > " U_NAMESPACE_BEGIN +const char TransliterationRule::fgClassID=0; + /** * Construct a new rule with the given input, output text, and other * attributes. A cursor position may be specified for the output text. diff --git a/icu4c/source/i18n/rbt_rule.h b/icu4c/source/i18n/rbt_rule.h index 136c848e86c..427707ab5c8 100644 --- a/icu4c/source/i18n/rbt_rule.h +++ b/icu4c/source/i18n/rbt_rule.h @@ -268,6 +268,20 @@ public: */ virtual UnicodeString& toRule(UnicodeString& pat, UBool escapeUnprintable) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + /** * Union the set of all characters that may be modified by this rule @@ -284,6 +298,12 @@ public: private: friend class StringMatcher; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/rbt_set.cpp b/icu4c/source/i18n/rbt_set.cpp index c86dc0e0dac..e3a096c53a4 100644 --- a/icu4c/source/i18n/rbt_set.cpp +++ b/icu4c/source/i18n/rbt_set.cpp @@ -150,6 +150,8 @@ static void maskingError(const U_NAMESPACE_QUALIFIER TransliterationRule& rule1, U_NAMESPACE_BEGIN +const char TransliterationRuleSet::fgClassID=0; + /** * Construct a new empty rule set. */ diff --git a/icu4c/source/i18n/rbt_set.h b/icu4c/source/i18n/rbt_set.h index b3e4e0a153d..72f3979329c 100644 --- a/icu4c/source/i18n/rbt_set.h +++ b/icu4c/source/i18n/rbt_set.h @@ -134,6 +134,28 @@ public: virtual UnicodeString& toRules(UnicodeString& result, UBool escapeUnprintable) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + /** * Return the set of all characters that may be modified * (getTarget=false) or emitted (getTarget=true) by this set. diff --git a/icu4c/source/i18n/remtrans.cpp b/icu4c/source/i18n/remtrans.cpp index f864771cdda..7d9aa559d0a 100644 --- a/icu4c/source/i18n/remtrans.cpp +++ b/icu4c/source/i18n/remtrans.cpp @@ -13,6 +13,8 @@ static const UChar ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, U_NAMESPACE_BEGIN +const char RemoveTransliterator::fgClassID=0; + /** * System registration hook. */ diff --git a/icu4c/source/i18n/remtrans.h b/icu4c/source/i18n/remtrans.h index 7bf3e246177..c3d13c1112f 100644 --- a/icu4c/source/i18n/remtrans.h +++ b/icu4c/source/i18n/remtrans.h @@ -48,12 +48,32 @@ public: virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, UBool isIncremental) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Factory method */ static Transliterator* _create(const UnicodeString& ID, Token context); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/sortkey.cpp b/icu4c/source/i18n/sortkey.cpp index 695bc7b7620..50976cf5594 100644 --- a/icu4c/source/i18n/sortkey.cpp +++ b/icu4c/source/i18n/sortkey.cpp @@ -39,6 +39,8 @@ U_NAMESPACE_BEGIN #define kInvalidHashCode ((int32_t)0) #define kEmptyHashCode ((int32_t)1) +const char CollationKey::fgClassID=0; + CollationKey::CollationKey() : fBogus(FALSE), fCount(0), fCapacity(0), fHashCode(kEmptyHashCode), fBytes(NULL) diff --git a/icu4c/source/i18n/strmatch.cpp b/icu4c/source/i18n/strmatch.cpp index 3fceb8dbd25..9dec03628d3 100644 --- a/icu4c/source/i18n/strmatch.cpp +++ b/icu4c/source/i18n/strmatch.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN const UChar EMPTY[] = { 0 }; // empty string: "" +const char StringMatcher::fgClassID=0; + StringMatcher::StringMatcher(const UnicodeString& theString, int32_t start, int32_t limit, diff --git a/icu4c/source/i18n/strmatch.h b/icu4c/source/i18n/strmatch.h index 296b9c08d46..3f52baffdea 100644 --- a/icu4c/source/i18n/strmatch.h +++ b/icu4c/source/i18n/strmatch.h @@ -150,6 +150,20 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico */ void resetMatch(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + /** * Union the set of all characters that may output by this object * into the given set. @@ -186,6 +200,12 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico * match. */ int32_t matchLimit; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/strrepl.cpp b/icu4c/source/i18n/strrepl.cpp index 577760ea93a..3c35125ddee 100644 --- a/icu4c/source/i18n/strrepl.cpp +++ b/icu4c/source/i18n/strrepl.cpp @@ -17,6 +17,8 @@ U_NAMESPACE_BEGIN const UChar EMPTY[] = { 0 }; // empty string: "" +const char StringReplacer::fgClassID=0; + /** * Construct a StringReplacer that sets the emits the given output * text and sets the cursor to the given position. diff --git a/icu4c/source/i18n/strrepl.h b/icu4c/source/i18n/strrepl.h index c6b62e3a17a..d5701c8e39c 100644 --- a/icu4c/source/i18n/strrepl.h +++ b/icu4c/source/i18n/strrepl.h @@ -63,6 +63,12 @@ class StringReplacer : public UnicodeFunctor, public UnicodeReplacer { */ const TransliterationRuleData* data; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -136,6 +142,20 @@ class StringReplacer : public UnicodeFunctor, public UnicodeReplacer { * UnicodeFunctor API */ virtual void setData(const TransliterationRuleData*); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/stsearch.cpp b/icu4c/source/i18n/stsearch.cpp index 89d5540e26b..c2d48823d27 100644 --- a/icu4c/source/i18n/stsearch.cpp +++ b/icu4c/source/i18n/stsearch.cpp @@ -13,6 +13,8 @@ U_NAMESPACE_BEGIN +const char StringSearch::fgClassID=0; + // public constructors and destructors ----------------------------------- StringSearch::StringSearch(const UnicodeString &pattern, diff --git a/icu4c/source/i18n/titletrn.cpp b/icu4c/source/i18n/titletrn.cpp index c2ffa7250dd..88acf9484cd 100644 --- a/icu4c/source/i18n/titletrn.cpp +++ b/icu4c/source/i18n/titletrn.cpp @@ -19,6 +19,8 @@ U_NAMESPACE_BEGIN +const char TitlecaseTransliterator::fgClassID=0; + /** * ID for this transliterator. */ diff --git a/icu4c/source/i18n/titletrn.h b/icu4c/source/i18n/titletrn.h index b587fec61ba..d0c43d61ec1 100644 --- a/icu4c/source/i18n/titletrn.h +++ b/icu4c/source/i18n/titletrn.h @@ -56,6 +56,20 @@ class U_I18N_API TitlecaseTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -74,6 +88,12 @@ class U_I18N_API TitlecaseTransliterator : public Transliterator { private: Locale loc; UChar* buffer; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/tolowtrn.cpp b/icu4c/source/i18n/tolowtrn.cpp index 9c3ba7d50f1..31ce5aa4839 100644 --- a/icu4c/source/i18n/tolowtrn.cpp +++ b/icu4c/source/i18n/tolowtrn.cpp @@ -16,6 +16,8 @@ U_NAMESPACE_BEGIN +const char LowercaseTransliterator::fgClassID=0; + const char LowercaseTransliterator::_ID[] = "Any-Lower"; /** diff --git a/icu4c/source/i18n/tolowtrn.h b/icu4c/source/i18n/tolowtrn.h index 4a7d96548ab..22ed79a4d18 100644 --- a/icu4c/source/i18n/tolowtrn.h +++ b/icu4c/source/i18n/tolowtrn.h @@ -49,6 +49,20 @@ class U_I18N_API LowercaseTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -63,6 +77,12 @@ class U_I18N_API LowercaseTransliterator : public Transliterator { Locale loc; UChar* buffer; static const char _ID[]; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/toupptrn.cpp b/icu4c/source/i18n/toupptrn.cpp index f72f26de39c..0c2c877786a 100644 --- a/icu4c/source/i18n/toupptrn.cpp +++ b/icu4c/source/i18n/toupptrn.cpp @@ -16,6 +16,8 @@ U_NAMESPACE_BEGIN +const char UppercaseTransliterator::fgClassID=0; + const char UppercaseTransliterator::_ID[] = "Any-Upper"; /** diff --git a/icu4c/source/i18n/toupptrn.h b/icu4c/source/i18n/toupptrn.h index 2a01592baea..e6dcc9f7310 100644 --- a/icu4c/source/i18n/toupptrn.h +++ b/icu4c/source/i18n/toupptrn.h @@ -49,6 +49,20 @@ class U_I18N_API UppercaseTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: @@ -64,6 +78,12 @@ class U_I18N_API UppercaseTransliterator : public Transliterator { Locale loc; UChar* buffer; static const char _ID[]; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/transreg.cpp b/icu4c/source/i18n/transreg.cpp index cd5ab3dc39a..ba5fe69f8e0 100644 --- a/icu4c/source/i18n/transreg.cpp +++ b/icu4c/source/i18n/transreg.cpp @@ -55,6 +55,8 @@ U_NAMESPACE_BEGIN // Alias //------------------------------------------------------------------ +const char TransliteratorAlias::fgClassID=0; + TransliteratorAlias::TransliteratorAlias(const UnicodeString& theAliasID) : ID(), aliasID(theAliasID), @@ -131,6 +133,20 @@ class Spec : public UObject { operator const UnicodeString&() const { return get(); } const UnicodeString& getTop() const { return top; } + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: void setupNext(); @@ -141,8 +157,16 @@ class Spec : public UObject { UBool isSpecLocale; // TRUE if spec is a locale UBool isNextLocale; // TRUE if nextSpec is a locale ResourceBundle* res; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char Spec::fgClassID=0; + Spec::Spec(const UnicodeString& theSpec) : top(theSpec) { UErrorCode status = U_ZERO_ERROR; CharString topch(top); @@ -349,8 +373,32 @@ public: void adoptPrototype(Transliterator* adopted); void setFactory(Transliterator::Factory factory, Transliterator::Token context); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char Entry::fgClassID=0; + Entry::Entry() { u.prototype = 0; compoundFilter = NULL; @@ -402,6 +450,8 @@ U_CDECL_END // class TransliteratorRegistry: Basic public API //---------------------------------------------------------------------- +const char TransliteratorRegistry::fgClassID=0; + TransliteratorRegistry::TransliteratorRegistry(UErrorCode& status) : registry(TRUE), specDAG(TRUE), diff --git a/icu4c/source/i18n/transreg.h b/icu4c/source/i18n/transreg.h index 4722ddf6a24..29232f2144b 100644 --- a/icu4c/source/i18n/transreg.h +++ b/icu4c/source/i18n/transreg.h @@ -58,6 +58,20 @@ class TransliteratorAlias : public UObject { */ Transliterator* create(UParseError&, UErrorCode&); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: // We actually come in two flavors: // 1. Simple alias @@ -73,6 +87,12 @@ class TransliteratorAlias : public UObject { Transliterator* trans; // owned const UnicodeSet* compoundFilter; // alias int32_t idSplitPoint; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; @@ -252,6 +272,20 @@ class TransliteratorRegistry : public UObject { const UnicodeString& target, UnicodeString& result); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: //---------------------------------------------------------------- @@ -331,6 +365,12 @@ class TransliteratorRegistry : public UObject { * Vector of public full IDs. */ UVector availableIDs; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/tridpars.cpp b/icu4c/source/i18n/tridpars.cpp index 2ba7eb0f6b1..30128d2874c 100644 --- a/icu4c/source/i18n/tridpars.cpp +++ b/icu4c/source/i18n/tridpars.cpp @@ -42,6 +42,8 @@ static Hashtable* SPECIAL_INVERSES = NULL; */ static UMTX LOCK = 0; +const char TransliteratorIDParser::Specs::fgClassID=0; + TransliteratorIDParser::Specs::Specs(const UnicodeString& s, const UnicodeString& t, const UnicodeString& v, UBool sawS, const UnicodeString& f) { @@ -52,6 +54,8 @@ TransliteratorIDParser::Specs::Specs(const UnicodeString& s, const UnicodeString filter = f; } +const char TransliteratorIDParser::SingleID::fgClassID=0; + TransliteratorIDParser::SingleID::SingleID(const UnicodeString& c, const UnicodeString& b, const UnicodeString& f) { canonID = c; diff --git a/icu4c/source/i18n/tridpars.h b/icu4c/source/i18n/tridpars.h index d8de3ca15de..5ca7b42f1d3 100644 --- a/icu4c/source/i18n/tridpars.h +++ b/icu4c/source/i18n/tridpars.h @@ -42,7 +42,7 @@ class UVector; * * @author Alan Liu */ -class TransliteratorIDParser : public UObject { +class TransliteratorIDParser /* not : public UObject because all methods are static */ { public: @@ -70,6 +70,28 @@ class TransliteratorIDParser : public UObject { Specs(const UnicodeString& s, const UnicodeString& t, const UnicodeString& v, UBool sawS, const UnicodeString& f); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + + private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; /** @@ -96,6 +118,28 @@ class TransliteratorIDParser : public UObject { const UnicodeString& f); SingleID(const UnicodeString& c, const UnicodeString& b); Transliterator* createInstance(); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + + private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; /** @@ -275,11 +319,13 @@ class TransliteratorIDParser : public UObject { static void cleanup(); private: - //---------------------------------------------------------------- // Private implementation //---------------------------------------------------------------- + // forbid instantiation + TransliteratorIDParser(); + /** * Parse an ID into component pieces. Take IDs of the form T, * T/V, S-T, S-T/V, or S/V-T. If the source is missing, return a diff --git a/icu4c/source/i18n/unesctrn.cpp b/icu4c/source/i18n/unesctrn.cpp index a08a12edf31..6f969204fac 100644 --- a/icu4c/source/i18n/unesctrn.cpp +++ b/icu4c/source/i18n/unesctrn.cpp @@ -68,6 +68,8 @@ static const UChar SPEC_Any[] = { END }; +const char UnescapeTransliterator::fgClassID=0; + /** * Factory methods. Ignore the context. */ diff --git a/icu4c/source/i18n/unesctrn.h b/icu4c/source/i18n/unesctrn.h index 6ea56d1b3f9..4606c815b39 100644 --- a/icu4c/source/i18n/unesctrn.h +++ b/icu4c/source/i18n/unesctrn.h @@ -71,6 +71,20 @@ class U_I18N_API UnescapeTransliterator : public Transliterator { */ virtual Transliterator* clone() const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -93,6 +107,12 @@ class U_I18N_API UnescapeTransliterator : public Transliterator { static Transliterator* _createAny(const UnicodeString& ID, Token context); static UChar* copySpec(const UChar* spec); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/uni2name.cpp b/icu4c/source/i18n/uni2name.cpp index 4bf5ed03120..ff68bccab54 100644 --- a/icu4c/source/i18n/uni2name.cpp +++ b/icu4c/source/i18n/uni2name.cpp @@ -17,6 +17,8 @@ U_NAMESPACE_BEGIN +const char UnicodeNameTransliterator::fgClassID=0; + const char UnicodeNameTransliterator::_ID[] = "Any-Name"; /** diff --git a/icu4c/source/i18n/uni2name.h b/icu4c/source/i18n/uni2name.h index 9bbf26d1160..67f03b21998 100644 --- a/icu4c/source/i18n/uni2name.h +++ b/icu4c/source/i18n/uni2name.h @@ -57,6 +57,20 @@ class U_I18N_API UnicodeNameTransliterator : public Transliterator { */ Transliterator* clone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -68,6 +82,12 @@ class U_I18N_API UnicodeNameTransliterator : public Transliterator { private: static const char _ID[]; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/unicode/coleitr.h b/icu4c/source/i18n/unicode/coleitr.h index e7a7345d7b9..6a66c90cdb1 100644 --- a/icu4c/source/i18n/unicode/coleitr.h +++ b/icu4c/source/i18n/unicode/coleitr.h @@ -255,6 +255,20 @@ public: */ void setOffset(int32_t newOffset, UErrorCode& status); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: // CollationElementIterator protected constructors -------------------------- @@ -312,6 +326,12 @@ private: * Indicates if m_data_ belongs to this object. */ UBool isDataOwned_; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // CollationElementIterator inline method defination -------------------------- diff --git a/icu4c/source/i18n/unicode/cpdtrans.h b/icu4c/source/i18n/unicode/cpdtrans.h index 5104a2643cf..795402ef354 100644 --- a/icu4c/source/i18n/unicode/cpdtrans.h +++ b/icu4c/source/i18n/unicode/cpdtrans.h @@ -184,6 +184,20 @@ public: virtual void handleTransliterate(Replaceable& text, UTransPosition& index, UBool incremental) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: friend class Transliterator; @@ -231,7 +245,12 @@ private: void computeMaximumContextLength(void); - + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + #ifdef U_USE_DEPRECATED_TRANSLITERATOR_API public: diff --git a/icu4c/source/i18n/unicode/dcfmtsym.h b/icu4c/source/i18n/unicode/dcfmtsym.h index 4f77a4b71c4..4c83a27f5ab 100644 --- a/icu4c/source/i18n/unicode/dcfmtsym.h +++ b/icu4c/source/i18n/unicode/dcfmtsym.h @@ -186,6 +186,20 @@ public: */ inline Locale getLocale() const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + #ifdef ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES /** * character used for zero. Different for Arabic, etc. @@ -497,6 +511,12 @@ private: static const char fgNumberElements[]; static const char fgCurrencyElements[]; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; diff --git a/icu4c/source/i18n/unicode/dtfmtsym.h b/icu4c/source/i18n/unicode/dtfmtsym.h index e2171921ea6..f53888fb1e6 100644 --- a/icu4c/source/i18n/unicode/dtfmtsym.h +++ b/icu4c/source/i18n/unicode/dtfmtsym.h @@ -250,6 +250,20 @@ public: */ void setLocalPatternChars(const UnicodeString& newLocalPatternChars); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Resource bundle file suffix and tag names used by this class. @@ -314,6 +328,12 @@ private: */ UnicodeString fLocalPatternChars; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + private: /* Sizes for the last resort string arrays */ diff --git a/icu4c/source/i18n/unicode/fieldpos.h b/icu4c/source/i18n/unicode/fieldpos.h index 369e79104fc..94eac0ec723 100644 --- a/icu4c/source/i18n/unicode/fieldpos.h +++ b/icu4c/source/i18n/unicode/fieldpos.h @@ -192,6 +192,20 @@ public: */ void setEndIndex(int32_t ei) { fEndIndex = ei; } + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Input: Desired field to determine start and end offsets for. @@ -210,6 +224,12 @@ private: * If the field does not occur in the text, 0 is returned. */ int32_t fEndIndex; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline FieldPosition& diff --git a/icu4c/source/i18n/unicode/fmtable.h b/icu4c/source/i18n/unicode/fmtable.h index 07b73ea1b85..92153c8190c 100644 --- a/icu4c/source/i18n/unicode/fmtable.h +++ b/icu4c/source/i18n/unicode/fmtable.h @@ -224,6 +224,20 @@ public: */ void adoptArray(Formattable* array, int32_t count); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Cleans up the memory for unwanted values. For example, the adopted @@ -256,6 +270,12 @@ private: } fValue; Type fType; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline Formattable* diff --git a/icu4c/source/i18n/unicode/hextouni.h b/icu4c/source/i18n/unicode/hextouni.h index bea56f4aa94..87b7cc6bca1 100644 --- a/icu4c/source/i18n/unicode/hextouni.h +++ b/icu4c/source/i18n/unicode/hextouni.h @@ -64,6 +64,12 @@ class U_I18N_API HexToUnicodeTransliterator : public Transliterator { */ int32_t affixCount; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -157,6 +163,20 @@ public: */ virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, UBool isIncremental) const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } }; inline HexToUnicodeTransliterator::~HexToUnicodeTransliterator() {} diff --git a/icu4c/source/i18n/unicode/nultrans.h b/icu4c/source/i18n/unicode/nultrans.h index 9f2729ad3bc..fe6eafedd1e 100644 --- a/icu4c/source/i18n/unicode/nultrans.h +++ b/icu4c/source/i18n/unicode/nultrans.h @@ -59,6 +59,28 @@ public: */ virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, UBool isIncremental) const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline NullTransliterator::NullTransliterator() : Transliterator(ID, 0) {} diff --git a/icu4c/source/i18n/unicode/sortkey.h b/icu4c/source/i18n/unicode/sortkey.h index f31e723513e..af47242770e 100644 --- a/icu4c/source/i18n/unicode/sortkey.h +++ b/icu4c/source/i18n/unicode/sortkey.h @@ -203,6 +203,20 @@ public: */ int32_t hashCode(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** * Returns an array of the collation key values as 16-bit integers. @@ -226,6 +240,12 @@ private: int32_t fCapacity; int32_t fHashCode; uint8_t* fBytes; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline UBool diff --git a/icu4c/source/i18n/unicode/stsearch.h b/icu4c/source/i18n/unicode/stsearch.h index 901095ce820..c4b2ed164ac 100644 --- a/icu4c/source/i18n/unicode/stsearch.h +++ b/icu4c/source/i18n/unicode/stsearch.h @@ -391,6 +391,20 @@ public: */ virtual SearchIterator * safeClone(void) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: // protected method ------------------------------------------------- @@ -461,6 +475,12 @@ private : * String search struct data */ UStringSearch *m_strsrch_; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/i18n/unicode/unifltlg.h b/icu4c/source/i18n/unicode/unifltlg.h index b9081d11218..a15787fc09e 100644 --- a/icu4c/source/i18n/unicode/unifltlg.h +++ b/icu4c/source/i18n/unicode/unifltlg.h @@ -30,7 +30,7 @@ class UnicodeFilter; * Unicode characters. Likewise, createAnd(g, NULL) returns g->clone(), * and createAnd(NULL, NULL) returns NULL. */ -class U_I18N_API UnicodeFilterLogic : public UObject { +class U_I18N_API UnicodeFilterLogic /* not : public UObject because all methods are static */ { public: diff --git a/icu4c/source/i18n/unicode/unitohex.h b/icu4c/source/i18n/unicode/unitohex.h index 2fc1946dc6d..2da59ee3540 100644 --- a/icu4c/source/i18n/unicode/unitohex.h +++ b/icu4c/source/i18n/unicode/unitohex.h @@ -82,6 +82,12 @@ private: */ UBool uppercase; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: /** @@ -196,6 +202,20 @@ public: */ virtual void handleTransliterate(Replaceable& text, UTransPosition& offsets, UBool isIncremental) const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } }; inline UnicodeToHexTransliterator::~UnicodeToHexTransliterator() {} diff --git a/icu4c/source/i18n/unitohex.cpp b/icu4c/source/i18n/unitohex.cpp index f8b8d97b5cc..9ae3f7bac31 100644 --- a/icu4c/source/i18n/unitohex.cpp +++ b/icu4c/source/i18n/unitohex.cpp @@ -13,6 +13,8 @@ U_NAMESPACE_BEGIN +const char UnicodeToHexTransliterator::fgClassID=0; + /** * ID for this transliterator. */ diff --git a/icu4c/source/i18n/utrans.cpp b/icu4c/source/i18n/utrans.cpp index d1b6bf4be24..ba327b17372 100644 --- a/icu4c/source/i18n/utrans.cpp +++ b/icu4c/source/i18n/utrans.cpp @@ -38,6 +38,12 @@ class ReplaceableGlue : public Replaceable { enum { BUF_PAD = 8 }; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: ReplaceableGlue(UReplaceable *replaceable, @@ -55,6 +61,20 @@ public: virtual void copy(int32_t start, int32_t limit, int32_t dest); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: virtual int32_t getLength() const; @@ -65,6 +85,8 @@ protected: }; +const char ReplaceableGlue::fgClassID=0; + ReplaceableGlue::ReplaceableGlue(UReplaceable *replaceable, UReplaceableCallbacks *funcCallback) : Replaceable() diff --git a/icu4c/source/layout/ArabicLayoutEngine.cpp b/icu4c/source/layout/ArabicLayoutEngine.cpp index 468272dcceb..9976b689cce 100644 --- a/icu4c/source/layout/ArabicLayoutEngine.cpp +++ b/icu4c/source/layout/ArabicLayoutEngine.cpp @@ -45,6 +45,8 @@ le_bool CharSubstitutionFilter::accept(LEGlyphID glyph) const return fFontInstance->canDisplay((LEUnicode) glyph); } +const char ArabicOpenTypeLayoutEngine::fgClassID=0; + ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const GlyphSubstitutionTableHeader *gsubTable) : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable) diff --git a/icu4c/source/layout/ArabicLayoutEngine.h b/icu4c/source/layout/ArabicLayoutEngine.h index 98597c66cb2..251c7e6e4ec 100644 --- a/icu4c/source/layout/ArabicLayoutEngine.h +++ b/icu4c/source/layout/ArabicLayoutEngine.h @@ -66,6 +66,20 @@ public: */ virtual ~ArabicOpenTypeLayoutEngine(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -106,6 +120,14 @@ protected: * @param success - output parameter set to an error code if the operation fails */ virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; /** diff --git a/icu4c/source/layout/ArabicShaping.cpp b/icu4c/source/layout/ArabicShaping.cpp index 43cf4190fb5..0f5517e5256 100644 --- a/icu4c/source/layout/ArabicShaping.cpp +++ b/icu4c/source/layout/ArabicShaping.cpp @@ -64,6 +64,8 @@ ArabicShaping::ShapeType ArabicShaping::getShapeType(LEUnicode c) return ST_NOSHAPE_NONE; } +const char GlyphShaper::fgClassID=0; + #if 0 const LETag GlyphShaper::isolFeatureTag = 0x69736F6C; // 'isol' const LETag GlyphShaper::initFeatureTag = 0x696E6974; // 'init' diff --git a/icu4c/source/layout/ArabicShaping.h b/icu4c/source/layout/ArabicShaping.h index 9636e21ea73..dd115b8ed8b 100644 --- a/icu4c/source/layout/ArabicShaping.h +++ b/icu4c/source/layout/ArabicShaping.h @@ -19,7 +19,7 @@ public: virtual void shape(le_int32 outIndex, le_int32 shapeOffset) = 0; }; -class ArabicShaping : public UObject { +class ArabicShaping /* not : public UObject because all methods are static */ { public: // shaping bit masks enum ShapingBitMasks @@ -54,6 +54,9 @@ public: static const le_uint8 glyphDefinitionTable[]; private: + // forbid instantiation + ArabicShaping(); + static ShapeType getShapeType(LEUnicode c); static const ShapeType shapeTypes[]; @@ -68,6 +71,20 @@ public: GlyphShaper(const LETag **outputTags); ~GlyphShaper(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: const LETag **charTags; @@ -85,6 +102,11 @@ private: static const LETag tagArray[]; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; class CharShaper : public Shaper diff --git a/icu4c/source/layout/ContextualGlyphSubstProc.cpp b/icu4c/source/layout/ContextualGlyphSubstProc.cpp index 16fddd29231..44ee08ed837 100644 --- a/icu4c/source/layout/ContextualGlyphSubstProc.cpp +++ b/icu4c/source/layout/ContextualGlyphSubstProc.cpp @@ -16,6 +16,8 @@ U_NAMESPACE_BEGIN +const char ContextualGlyphSubstitutionProcessor::fgClassID=0; + ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader) : StateTableProcessor(morphSubtableHeader) { diff --git a/icu4c/source/layout/ContextualGlyphSubstProc.h b/icu4c/source/layout/ContextualGlyphSubstProc.h index 25d93069072..7be36cd8aaf 100644 --- a/icu4c/source/layout/ContextualGlyphSubstProc.h +++ b/icu4c/source/layout/ContextualGlyphSubstProc.h @@ -29,6 +29,20 @@ public: ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader); virtual ~ContextualGlyphSubstitutionProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: ContextualGlyphSubstitutionProcessor(); @@ -39,6 +53,14 @@ protected: le_int32 markGlyph; const ContextualGlyphSubstitutionHeader *contextualGlyphSubstitutionHeader; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/GXLayoutEngine.cpp b/icu4c/source/layout/GXLayoutEngine.cpp index 753683cc144..5273264a3cb 100644 --- a/icu4c/source/layout/GXLayoutEngine.cpp +++ b/icu4c/source/layout/GXLayoutEngine.cpp @@ -14,6 +14,8 @@ U_NAMESPACE_BEGIN +const char GXLayoutEngine::fgClassID=0; + GXLayoutEngine::GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const MorphTableHeader *morphTable) : LayoutEngine(fontInstance, scriptCode, languageCode), fMorphTable(morphTable) { diff --git a/icu4c/source/layout/GXLayoutEngine.h b/icu4c/source/layout/GXLayoutEngine.h index 3b508973591..e15caf7b339 100644 --- a/icu4c/source/layout/GXLayoutEngine.h +++ b/icu4c/source/layout/GXLayoutEngine.h @@ -51,6 +51,20 @@ public: */ virtual ~GXLayoutEngine(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -96,6 +110,14 @@ protected: */ virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/GlyphIterator.cpp b/icu4c/source/layout/GlyphIterator.cpp index 50503e7f663..5bfc9b71741 100644 --- a/icu4c/source/layout/GlyphIterator.cpp +++ b/icu4c/source/layout/GlyphIterator.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char GlyphIterator::fgClassID=0; + GlyphIterator::GlyphIterator(LEGlyphID *theGlyphs, GlyphPositionAdjustment *theGlyphPositionAdjustments, le_int32 theGlyphCount, le_bool rightToLeft, le_uint16 theLookupFlags, LETag theFeatureTag, const LETag *theGlyphTags[], const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader) diff --git a/icu4c/source/layout/GlyphIterator.h b/icu4c/source/layout/GlyphIterator.h index 6ee32ef3ac9..4a5cc994941 100644 --- a/icu4c/source/layout/GlyphIterator.h +++ b/icu4c/source/layout/GlyphIterator.h @@ -64,6 +64,20 @@ public: void adjustCursiveLastGlyphPositionAdjustment(float xPlacmentAdjust, float yPlacementAdjust, float xAdvanceAdjust, float yAdvanceAdjust); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: GlyphIterator(); le_bool filterGlyph(le_uint32 index) const; @@ -86,6 +100,12 @@ private: const LETag **glyphTags; const GlyphClassDefinitionTable *glyphClassDefinitionTable; const MarkAttachClassDefinitionTable *markAttachClassDefinitionTable; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/GlyphPositionAdjustments.h b/icu4c/source/layout/GlyphPositionAdjustments.h index 7dd5060b61f..95cf6dc5c75 100644 --- a/icu4c/source/layout/GlyphPositionAdjustments.h +++ b/icu4c/source/layout/GlyphPositionAdjustments.h @@ -39,6 +39,20 @@ public: void adjustXAdvance(float xAdjustment); void adjustYAdvance(float yAdjustment); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: float xPlacement; float yPlacement; @@ -46,6 +60,12 @@ private: float yAdvance; le_int32 baseOffset; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline GlyphPositionAdjustment::GlyphPositionAdjustment() diff --git a/icu4c/source/layout/GlyphPositioningTables.cpp b/icu4c/source/layout/GlyphPositioningTables.cpp index ead6d1e8e87..f7f420a3eb2 100644 --- a/icu4c/source/layout/GlyphPositioningTables.cpp +++ b/icu4c/source/layout/GlyphPositioningTables.cpp @@ -16,6 +16,8 @@ U_NAMESPACE_BEGIN +const char GlyphPositionAdjustment::fgClassID=0; + void GlyphPositioningTableHeader::process(LEGlyphID *glyphs, GlyphPositionAdjustment *glyphPositionAdjustments, const LETag **glyphTags, le_int32 glyphCount, le_bool rightToLeft, LETag scriptTag, LETag languageTag, diff --git a/icu4c/source/layout/GlyphPosnLookupProc.cpp b/icu4c/source/layout/GlyphPosnLookupProc.cpp index 71c69aa70db..6c55d1a9c82 100644 --- a/icu4c/source/layout/GlyphPosnLookupProc.cpp +++ b/icu4c/source/layout/GlyphPosnLookupProc.cpp @@ -32,6 +32,8 @@ U_NAMESPACE_BEGIN typedef ContextualSubstitutionSubtable ContextualPositioningSubtable; typedef ChainingContextualSubstitutionSubtable ChainingContextualPositioningSubtable; +const char GlyphPositioningLookupProcessor::fgClassID=0; + GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor( const GlyphPositioningTableHeader *glyphPositioningTableHeader, LETag scriptTag, LETag languageTag, const LETag *featureOrder) diff --git a/icu4c/source/layout/GlyphPosnLookupProc.h b/icu4c/source/layout/GlyphPosnLookupProc.h index 4572351aee7..171fc64edb5 100644 --- a/icu4c/source/layout/GlyphPosnLookupProc.h +++ b/icu4c/source/layout/GlyphPosnLookupProc.h @@ -31,8 +31,30 @@ public: virtual le_uint32 applySubtable(const LookupSubtable *lookupSubtable, le_uint16 lookupType, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: GlyphPositioningLookupProcessor(); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/GlyphSubstLookupProc.cpp b/icu4c/source/layout/GlyphSubstLookupProc.cpp index d7574502a68..73aa99331b7 100644 --- a/icu4c/source/layout/GlyphSubstLookupProc.cpp +++ b/icu4c/source/layout/GlyphSubstLookupProc.cpp @@ -25,6 +25,8 @@ U_NAMESPACE_BEGIN +const char GlyphSubstitutionLookupProcessor::fgClassID=0; + GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor( const GlyphSubstitutionTableHeader *glyphSubstitutionTableHeader, LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter, const LETag *featureOrder) diff --git a/icu4c/source/layout/GlyphSubstLookupProc.h b/icu4c/source/layout/GlyphSubstLookupProc.h index 6dd89cbc3e0..e2cdd503485 100644 --- a/icu4c/source/layout/GlyphSubstLookupProc.h +++ b/icu4c/source/layout/GlyphSubstLookupProc.h @@ -32,11 +32,31 @@ public: virtual le_uint32 applySubtable(const LookupSubtable *lookupSubtable, le_uint16 lookupType, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const; + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: GlyphSubstitutionLookupProcessor(); private: const LEGlyphFilter *fFilter; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/HebrewShaping.h b/icu4c/source/layout/HebrewShaping.h index 4d3be7c78c9..6b08b445e43 100644 --- a/icu4c/source/layout/HebrewShaping.h +++ b/icu4c/source/layout/HebrewShaping.h @@ -13,13 +13,17 @@ U_NAMESPACE_BEGIN -class HebrewShaping : public UObject { +class HebrewShaping /* not : public UObject because all methods are static */ { public: static void shape(const LEUnicode *chars, le_int32 offset, le_int32 charCount, le_int32 charMax, le_bool rightToLeft, const LETag **tags); static const le_uint8 glyphSubstitutionTable[]; static const le_uint8 glyphDefinitionTable[]; + +private: + // forbid instantiation + HebrewShaping(); }; U_NAMESPACE_END diff --git a/icu4c/source/layout/IndicLayoutEngine.cpp b/icu4c/source/layout/IndicLayoutEngine.cpp index a42f1ccb906..7a362023df1 100644 --- a/icu4c/source/layout/IndicLayoutEngine.cpp +++ b/icu4c/source/layout/IndicLayoutEngine.cpp @@ -22,6 +22,8 @@ U_NAMESPACE_BEGIN +const char IndicOpenTypeLayoutEngine::fgClassID=0; + IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const GlyphSubstitutionTableHeader *gsubTable) : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable) diff --git a/icu4c/source/layout/IndicLayoutEngine.h b/icu4c/source/layout/IndicLayoutEngine.h index d4815f885f5..e4c19d5f185 100644 --- a/icu4c/source/layout/IndicLayoutEngine.h +++ b/icu4c/source/layout/IndicLayoutEngine.h @@ -71,6 +71,20 @@ public: */ virtual ~IndicOpenTypeLayoutEngine(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** @@ -128,6 +142,14 @@ protected: // Output: glyphs, char indices virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, const LETag **featureTags, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/IndicRearrangementProcessor.cpp b/icu4c/source/layout/IndicRearrangementProcessor.cpp index 330d2e34a9e..f5695e5b795 100644 --- a/icu4c/source/layout/IndicRearrangementProcessor.cpp +++ b/icu4c/source/layout/IndicRearrangementProcessor.cpp @@ -16,6 +16,8 @@ U_NAMESPACE_BEGIN +const char IndicRearrangementProcessor::fgClassID=0; + IndicRearrangementProcessor::IndicRearrangementProcessor(const MorphSubtableHeader *morphSubtableHeader) : StateTableProcessor(morphSubtableHeader) { diff --git a/icu4c/source/layout/IndicRearrangementProcessor.h b/icu4c/source/layout/IndicRearrangementProcessor.h index ea8cc14e5e6..dd0622c694d 100644 --- a/icu4c/source/layout/IndicRearrangementProcessor.h +++ b/icu4c/source/layout/IndicRearrangementProcessor.h @@ -31,12 +31,34 @@ public: IndicRearrangementProcessor(const MorphSubtableHeader *morphSubtableHeader); virtual ~IndicRearrangementProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: le_int32 firstGlyph; le_int32 lastGlyph; const IndicRearrangementStateEntry *entryTable; const IndicRearrangementSubtableHeader *indicRearrangementSubtableHeader; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/IndicReordering.cpp b/icu4c/source/layout/IndicReordering.cpp index c98245f7fd5..650148b0b37 100644 --- a/icu4c/source/layout/IndicReordering.cpp +++ b/icu4c/source/layout/IndicReordering.cpp @@ -44,6 +44,12 @@ private: } } + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: ReorderingOutput(LEUnicode *outChars, le_int32 *charIndices, const LETag **charTags) : fOutIndex(0), fOutChars(outChars), fCharIndices(charIndices), fCharTags(charTags), @@ -131,8 +137,24 @@ public: { return fOutIndex; } + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } }; +const char ReorderingOutput::fgClassID=0; + enum { C_DOTTED_CIRCLE = 0x25CC diff --git a/icu4c/source/layout/IndicReordering.h b/icu4c/source/layout/IndicReordering.h index 5e16671b0f0..51066eb5ba6 100644 --- a/icu4c/source/layout/IndicReordering.h +++ b/icu4c/source/layout/IndicReordering.h @@ -125,7 +125,7 @@ struct IndicClassTable static const IndicClassTable *getScriptClassTable(le_int32 scriptCode); }; -class IndicReordering : public UObject { +class IndicReordering /* not : public UObject because all methods are static */ { public: static le_int32 getWorstCaseExpansion(le_int32 scriptCode); @@ -138,6 +138,9 @@ public: static const LETag *getFeatureOrder(); private: + // do not instantiate + IndicReordering(); + static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount); }; diff --git a/icu4c/source/layout/LayoutEngine.cpp b/icu4c/source/layout/LayoutEngine.cpp index d65bcc5be2e..c52885f3549 100644 --- a/icu4c/source/layout/LayoutEngine.cpp +++ b/icu4c/source/layout/LayoutEngine.cpp @@ -79,6 +79,8 @@ LEUnicode32 DefaultCharMapper::mapChar(LEUnicode32 ch) const return ch; } +const char LayoutEngine::fgClassID=0; + LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode) : fGlyphCount(0), fGlyphs(NULL), fCharIndices(NULL), fPositions(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode) diff --git a/icu4c/source/layout/LayoutEngine.h b/icu4c/source/layout/LayoutEngine.h index 131ab4939af..4ca1c6982d1 100644 --- a/icu4c/source/layout/LayoutEngine.h +++ b/icu4c/source/layout/LayoutEngine.h @@ -463,6 +463,27 @@ public: */ static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/LigatureSubstProc.cpp b/icu4c/source/layout/LigatureSubstProc.cpp index 9f8406c0426..5716fa9d54d 100644 --- a/icu4c/source/layout/LigatureSubstProc.cpp +++ b/icu4c/source/layout/LigatureSubstProc.cpp @@ -20,6 +20,8 @@ U_NAMESPACE_BEGIN #define SignBit(m) ((ExtendedComplement(m) >> 1) & (m)) #define SignExtend(v,m) (((v) & SignBit(m))? ((v) | ExtendedComplement(m)): (v)) +const char LigatureSubstitutionProcessor::fgClassID=0; + LigatureSubstitutionProcessor::LigatureSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader) : StateTableProcessor(morphSubtableHeader) { diff --git a/icu4c/source/layout/LigatureSubstProc.h b/icu4c/source/layout/LigatureSubstProc.h index b2a436d58c3..dd1c7fd4a61 100644 --- a/icu4c/source/layout/LigatureSubstProc.h +++ b/icu4c/source/layout/LigatureSubstProc.h @@ -31,6 +31,20 @@ public: LigatureSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader); virtual ~LigatureSubstitutionProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: LigatureSubstitutionProcessor(); @@ -45,6 +59,14 @@ protected: le_int16 m; const LigatureSubstitutionHeader *ligatureSubstitutionHeader; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/LookupProcessor.cpp b/icu4c/source/layout/LookupProcessor.cpp index bc259d2140b..9d74cc621d4 100644 --- a/icu4c/source/layout/LookupProcessor.cpp +++ b/icu4c/source/layout/LookupProcessor.cpp @@ -19,6 +19,8 @@ U_NAMESPACE_BEGIN +const char LookupProcessor::fgClassID=0; + const LETag LookupProcessor::notSelected = 0x00000000; const LETag LookupProcessor::defaultFeature = 0xFFFFFFFF; diff --git a/icu4c/source/layout/LookupProcessor.h b/icu4c/source/layout/LookupProcessor.h index 83139efaaea..07d7ced73da 100644 --- a/icu4c/source/layout/LookupProcessor.h +++ b/icu4c/source/layout/LookupProcessor.h @@ -36,6 +36,20 @@ public: virtual ~LookupProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: LookupProcessor(const char *baseAddress, Offset scriptListOffset, Offset featureListOffset, Offset lookupListOffset, @@ -53,6 +67,14 @@ protected: le_uint16 *lookupOrderArray; le_uint32 lookupOrderCount; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/OpenTypeLayoutEngine.cpp b/icu4c/source/layout/OpenTypeLayoutEngine.cpp index e95021188cd..f5f920cd145 100644 --- a/icu4c/source/layout/OpenTypeLayoutEngine.cpp +++ b/icu4c/source/layout/OpenTypeLayoutEngine.cpp @@ -19,6 +19,8 @@ U_NAMESPACE_BEGIN +const char OpenTypeLayoutEngine::fgClassID=0; + OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const GlyphSubstitutionTableHeader *gsubTable) : LayoutEngine(fontInstance, scriptCode, languageCode), fFeatureTags(NULL), fGSUBTable(gsubTable), diff --git a/icu4c/source/layout/OpenTypeLayoutEngine.h b/icu4c/source/layout/OpenTypeLayoutEngine.h index 7639007291d..229c5e252ed 100644 --- a/icu4c/source/layout/OpenTypeLayoutEngine.h +++ b/icu4c/source/layout/OpenTypeLayoutEngine.h @@ -98,6 +98,20 @@ public: */ static LETag getLangSysTag(le_int32 languageCode); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: /** @@ -111,6 +125,12 @@ private: */ static const LETag scriptTags[]; + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + protected: /** * An array of pointers to four byte feature tags. diff --git a/icu4c/source/layout/SegmentArrayProcessor.cpp b/icu4c/source/layout/SegmentArrayProcessor.cpp index 4a633797948..7e2336a25fc 100644 --- a/icu4c/source/layout/SegmentArrayProcessor.cpp +++ b/icu4c/source/layout/SegmentArrayProcessor.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char SegmentArrayProcessor::fgClassID=0; + SegmentArrayProcessor::SegmentArrayProcessor() { } diff --git a/icu4c/source/layout/SegmentArrayProcessor.h b/icu4c/source/layout/SegmentArrayProcessor.h index 9e6610fc35d..5043937ee2e 100644 --- a/icu4c/source/layout/SegmentArrayProcessor.h +++ b/icu4c/source/layout/SegmentArrayProcessor.h @@ -25,11 +25,33 @@ public: virtual ~SegmentArrayProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: SegmentArrayProcessor(); protected: const SegmentArrayLookupTable *segmentArrayLookupTable; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/SegmentSingleProcessor.cpp b/icu4c/source/layout/SegmentSingleProcessor.cpp index 7d49db2a72d..d2ececaaebd 100644 --- a/icu4c/source/layout/SegmentSingleProcessor.cpp +++ b/icu4c/source/layout/SegmentSingleProcessor.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char SegmentSingleProcessor::fgClassID=0; + SegmentSingleProcessor::SegmentSingleProcessor() { } diff --git a/icu4c/source/layout/SegmentSingleProcessor.h b/icu4c/source/layout/SegmentSingleProcessor.h index 18576842c3c..e13860fa2ec 100644 --- a/icu4c/source/layout/SegmentSingleProcessor.h +++ b/icu4c/source/layout/SegmentSingleProcessor.h @@ -25,11 +25,33 @@ public: virtual ~SegmentSingleProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: SegmentSingleProcessor(); protected: const SegmentSingleLookupTable *segmentSingleLookupTable; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/SimpleArrayProcessor.cpp b/icu4c/source/layout/SimpleArrayProcessor.cpp index fbc1fa9d9a2..72fa3da290f 100644 --- a/icu4c/source/layout/SimpleArrayProcessor.cpp +++ b/icu4c/source/layout/SimpleArrayProcessor.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char SimpleArrayProcessor::fgClassID=0; + SimpleArrayProcessor::SimpleArrayProcessor() { } diff --git a/icu4c/source/layout/SimpleArrayProcessor.h b/icu4c/source/layout/SimpleArrayProcessor.h index d1ccea07b06..18072b8a52f 100644 --- a/icu4c/source/layout/SimpleArrayProcessor.h +++ b/icu4c/source/layout/SimpleArrayProcessor.h @@ -25,11 +25,33 @@ public: virtual ~SimpleArrayProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: SimpleArrayProcessor(); protected: const SimpleArrayLookupTable *simpleArrayLookupTable; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/SingleTableProcessor.cpp b/icu4c/source/layout/SingleTableProcessor.cpp index b5a5c63fa55..22be7c14450 100644 --- a/icu4c/source/layout/SingleTableProcessor.cpp +++ b/icu4c/source/layout/SingleTableProcessor.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char SingleTableProcessor::fgClassID=0; + SingleTableProcessor::SingleTableProcessor() { } diff --git a/icu4c/source/layout/SingleTableProcessor.h b/icu4c/source/layout/SingleTableProcessor.h index 9d7efea61fc..e1cd01fc3ba 100644 --- a/icu4c/source/layout/SingleTableProcessor.h +++ b/icu4c/source/layout/SingleTableProcessor.h @@ -25,11 +25,33 @@ public: virtual ~SingleTableProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: SingleTableProcessor(); protected: const SingleTableLookupTable *singleTableLookupTable; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/SubtableProcessor.cpp b/icu4c/source/layout/SubtableProcessor.cpp index 647e95f8c27..f28d3d196b2 100644 --- a/icu4c/source/layout/SubtableProcessor.cpp +++ b/icu4c/source/layout/SubtableProcessor.cpp @@ -12,6 +12,8 @@ U_NAMESPACE_BEGIN +const char SubtableProcessor::fgClassID=0; + SubtableProcessor::SubtableProcessor() { } diff --git a/icu4c/source/layout/SubtableProcessor.h b/icu4c/source/layout/SubtableProcessor.h index ea55aea6efd..e5385e24f7c 100644 --- a/icu4c/source/layout/SubtableProcessor.h +++ b/icu4c/source/layout/SubtableProcessor.h @@ -18,6 +18,20 @@ public: virtual void process(LEGlyphID *glyphs, le_int32 *charIndices, le_int32 glyph) = 0; virtual ~SubtableProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: SubtableProcessor(const MorphSubtableHeader *morphSubtableHeader); @@ -28,6 +42,14 @@ protected: FeatureFlags subtableFeatures; const MorphSubtableHeader *subtableHeader; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/ThaiLayoutEngine.cpp b/icu4c/source/layout/ThaiLayoutEngine.cpp index 116e84ed154..dc27ba766ac 100644 --- a/icu4c/source/layout/ThaiLayoutEngine.cpp +++ b/icu4c/source/layout/ThaiLayoutEngine.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char ThaiLayoutEngine::fgClassID=0; + ThaiLayoutEngine::ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode) : LayoutEngine(fontInstance, scriptCode, languageCode) { diff --git a/icu4c/source/layout/ThaiLayoutEngine.h b/icu4c/source/layout/ThaiLayoutEngine.h index a2acc165377..6efead237d1 100644 --- a/icu4c/source/layout/ThaiLayoutEngine.h +++ b/icu4c/source/layout/ThaiLayoutEngine.h @@ -45,6 +45,20 @@ public: */ virtual ~ThaiLayoutEngine(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: /** * A small integer indicating which Thai encoding @@ -87,6 +101,14 @@ protected: */ virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/ThaiShaping.h b/icu4c/source/layout/ThaiShaping.h index 0553ab67ed4..02ea2cd04d9 100644 --- a/icu4c/source/layout/ThaiShaping.h +++ b/icu4c/source/layout/ThaiShaping.h @@ -32,7 +32,7 @@ public: virtual le_bool filter(LEGlyphID glyph); }; -class ThaiShaping : public UObject { +class ThaiShaping /* not : public UObject because all methods are static */ { public: enum { @@ -83,6 +83,8 @@ public: LEUnicode errorChar, LEUnicode *output, le_int32 *charIndicies); private: + // forbid instantiation + ThaiShaping(); static const le_uint8 classTable[]; static const StateTransition thaiStateTable[][classCount]; diff --git a/icu4c/source/layout/TrimmedArrayProcessor.cpp b/icu4c/source/layout/TrimmedArrayProcessor.cpp index 58a08b6a1ae..e80eacc2abf 100644 --- a/icu4c/source/layout/TrimmedArrayProcessor.cpp +++ b/icu4c/source/layout/TrimmedArrayProcessor.cpp @@ -15,6 +15,8 @@ U_NAMESPACE_BEGIN +const char TrimmedArrayProcessor::fgClassID=0; + TrimmedArrayProcessor::TrimmedArrayProcessor() { } diff --git a/icu4c/source/layout/TrimmedArrayProcessor.h b/icu4c/source/layout/TrimmedArrayProcessor.h index 620f2f27627..38bf373b5de 100644 --- a/icu4c/source/layout/TrimmedArrayProcessor.h +++ b/icu4c/source/layout/TrimmedArrayProcessor.h @@ -25,6 +25,20 @@ public: virtual ~TrimmedArrayProcessor(); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private: TrimmedArrayProcessor(); @@ -32,6 +46,14 @@ protected: le_int16 firstGlyph; le_int16 lastGlyph; const TrimmedArrayLookupTable *trimmedArrayLookupTable; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; U_NAMESPACE_END diff --git a/icu4c/source/layout/loengine.cpp b/icu4c/source/layout/loengine.cpp index ae5b4178b2a..5e33d12e020 100644 --- a/icu4c/source/layout/loengine.cpp +++ b/icu4c/source/layout/loengine.cpp @@ -14,4 +14,4 @@ * exported by the build... */ - +const char ICULayoutEngine::fgClassID=0; diff --git a/icu4c/source/layout/unicode/loengine.h b/icu4c/source/layout/unicode/loengine.h index bb8ddd6626a..bf686e671ba 100644 --- a/icu4c/source/layout/unicode/loengine.h +++ b/icu4c/source/layout/unicode/loengine.h @@ -220,6 +220,28 @@ public: static ICULayoutEngine *createInstance(const LEFontInstance *fontInstance, UScriptCode script, Locale &locale, UErrorCode &success); + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; inline ICULayoutEngine::ICULayoutEngine() diff --git a/icu4c/source/test/intltest/reptest.cpp b/icu4c/source/test/intltest/reptest.cpp index 0a932d86a16..5a77b597039 100644 --- a/icu4c/source/test/intltest/reptest.cpp +++ b/icu4c/source/test/intltest/reptest.cpp @@ -37,6 +37,13 @@ class TestReplaceable : public Replaceable { UnicodeString styles; static const UChar defaultStyle; + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; + public: TestReplaceable (const UnicodeString& text, const UnicodeString& newStyles) { @@ -70,6 +77,20 @@ public: chars.extractBetween(start, limit, result); } + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: virtual int32_t getLength() const { return chars.length(); @@ -115,6 +136,8 @@ protected: } }; +const char TestReplaceable::fgClassID=0; + const UChar TestReplaceable::defaultStyle = 0x005F; void diff --git a/icu4c/source/test/intltest/srchtest.cpp b/icu4c/source/test/intltest/srchtest.cpp index c672dedd31a..32bcfcbf65d 100644 --- a/icu4c/source/test/intltest/srchtest.cpp +++ b/icu4c/source/test/intltest/srchtest.cpp @@ -1987,11 +1987,36 @@ public: void setOffset(int32_t position, UErrorCode &status); int32_t getOffset() const; SearchIterator* safeClone() const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + protected: int32_t handleNext(int32_t position, UErrorCode &status); int32_t handlePrev(int32_t position, UErrorCode &status); + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; +const char TempSearch::fgClassID=0; + TempSearch::TempSearch() : SearchIterator() { } diff --git a/icu4c/source/test/intltest/transrt.cpp b/icu4c/source/test/intltest/transrt.cpp index 8b5dd15638a..038f0cc8821 100644 --- a/icu4c/source/test/intltest/transrt.cpp +++ b/icu4c/source/test/intltest/transrt.cpp @@ -216,20 +216,41 @@ UBool LegalGreek::isRho(UChar c) { // AbbreviatedUnicodeSetIterator Interface --------------------------------------------- class AbbreviatedUnicodeSetIterator : public UnicodeSetIterator { - public : AbbreviatedUnicodeSetIterator(); virtual ~AbbreviatedUnicodeSetIterator(); void reset(UnicodeSet& set, UBool abb = FALSE); + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + private : UBool abbreviated; virtual void loadRange(int32_t range); + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; }; // AbbreviatedUnicodeSetIterator Implementation --------------------------------------- +const char AbbreviatedUnicodeSetIterator::fgClassID=0; + AbbreviatedUnicodeSetIterator::AbbreviatedUnicodeSetIterator() : UnicodeSetIterator(), abbreviated(FALSE) { }