<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>ICU 52.1: uobject.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">ICU 52.1  <span id="projectnumber">52.1</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.1.2 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_bdd9a5d540de89e9fe90efdfc6973a4f.html">common</a></li><li class="navelem"><a class="el" href="dir_f59c6450ff718ff1b085cfd1c36acbd7.html">unicode</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#nested-classes">Data Structures</a> | <a href="#namespaces">Namespaces</a> | <a href="#define-members">Macros</a> | <a href="#typedef-members">Typedefs</a> </div> <div class="headertitle"> <div class="title">uobject.h File Reference</div> </div> </div><!--header--> <div class="contents"> <p>C++ API: Common ICU base class UObject. <a href="#details">More...</a></p> <div class="textblock"><code>#include "<a class="el" href="utypes_8h_source.html">unicode/utypes.h</a>"</code><br/> </div> <p><a href="uobject_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="nested-classes"></a> Data Structures</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1UMemory.html">icu::UMemory</a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="classicu_1_1UMemory.html" title="UMemory is the common ICU base class.">UMemory</a> is the common ICU base class. <a href="classicu_1_1UMemory.html#details">More...</a><br/></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1UObject.html">icu::UObject</a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="classicu_1_1UObject.html" title="UObject is the common ICU "boilerplate" class.">UObject</a> is the common ICU "boilerplate" class. <a href="classicu_1_1UObject.html#details">More...</a><br/></td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="namespaces"></a> Namespaces</h2></td></tr> <tr class="memitem:namespaceicu"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceicu.html">icu</a></td></tr> <tr class="memdesc:namespaceicu"><td class="mdescLeft"> </td><td class="mdescRight">File <a class="el" href="coll_8h.html" title="C++ API: Collation Service.">coll.h</a>. <br/></td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="define-members"></a> Macros</h2></td></tr> <tr class="memitem:a0415b3e188980bcb82e31c091265f34b"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="uobject_8h.html#a0415b3e188980bcb82e31c091265f34b">UOBJECT_DEFINE_RTTI_IMPLEMENTATION</a>(myClass)</td></tr> <tr class="memdesc:a0415b3e188980bcb82e31c091265f34b"><td class="mdescLeft"> </td><td class="mdescRight">This is a simple macro to add ICU RTTI to an ICU object implementation. <a href="#a0415b3e188980bcb82e31c091265f34b"></a><br/></td></tr> <tr class="memitem:aa53bdd883d784e4c951b051faffc29d0"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="uobject_8h.html#aa53bdd883d784e4c951b051faffc29d0">UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION</a>(myClass)</td></tr> <tr class="memdesc:aa53bdd883d784e4c951b051faffc29d0"><td class="mdescLeft"> </td><td class="mdescRight">This macro adds ICU RTTI to an ICU abstract class implementation. <a href="#aa53bdd883d784e4c951b051faffc29d0"></a><br/></td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="typedef-members"></a> Typedefs</h2></td></tr> <tr class="memitem:a22af10545208a455a6e884008df48e9f"><td class="memItemLeft" align="right" valign="top">typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f">UClassID</a></td></tr> <tr class="memdesc:a22af10545208a455a6e884008df48e9f"><td class="mdescLeft"> </td><td class="mdescRight">UClassID is used to identify classes without using the compiler's RTTI. <a href="#a22af10545208a455a6e884008df48e9f"></a><br/></td></tr> </table> <a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>C++ API: Common ICU base class UObject. </p> <p>Definition in file <a class="el" href="uobject_8h_source.html">uobject.h</a>.</p> </div><h2>Macro Definition Documentation</h2> <a class="anchor" id="aa53bdd883d784e4c951b051faffc29d0"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">myClass</td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <b>Value:</b><div class="fragment"><div class="line"><a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a> U_EXPORT2 myClass::getStaticClassID() { \</div> <div class="line"> static <span class="keywordtype">char</span> classID = 0; \</div> <div class="line"> return (<a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a>)&classID; \</div> <div class="line"> }</div> </div><!-- fragment --> <p>This macro adds ICU RTTI to an ICU abstract class implementation. </p> <p>This macro should be invoked in *.cpp files. The corresponding header should declare getStaticClassID.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">myClass</td><td>The name of the class that needs RTTI defined. </td></tr> </table> </dd> </dl> <dl class="internal"><dt><b><a class="el" href="internal.html#_internal000176">Internal:</a></b></dt><dd>Do not use. This API is for internal use only. </dd></dl> <p>Definition at line <a class="el" href="uobject_8h_source.html#l00310">310</a> of file <a class="el" href="uobject_8h_source.html">uobject.h</a>.</p> </div> </div> <a class="anchor" id="a0415b3e188980bcb82e31c091265f34b"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">myClass</td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <b>Value:</b><div class="fragment"><div class="line"><a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a> U_EXPORT2 myClass::getStaticClassID() { \</div> <div class="line"> static <span class="keywordtype">char</span> classID = 0; \</div> <div class="line"> return (<a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a>)&classID; \</div> <div class="line"> } <a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">\</a></div> <div class="line"><a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI."> UClassID</a> myClass::getDynamicClassID() const \</div> <div class="line"> { <span class="keywordflow">return</span> myClass::getStaticClassID(); }</div> </div><!-- fragment --> <p>This is a simple macro to add ICU RTTI to an ICU object implementation. </p> <p>This does not go into the header. This should only be used in *.cpp files.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">myClass</td><td>The name of the class that needs RTTI defined. </td></tr> </table> </dd> </dl> <dl class="internal"><dt><b><a class="el" href="internal.html#_internal000175">Internal:</a></b></dt><dd>Do not use. This API is for internal use only. </dd></dl> <p>Definition at line <a class="el" href="uobject_8h_source.html#l00293">293</a> of file <a class="el" href="uobject_8h_source.html">uobject.h</a>.</p> </div> </div> <h2>Typedef Documentation</h2> <a class="anchor" id="a22af10545208a455a6e884008df48e9f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef void* <a class="el" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f">UClassID</a></td> </tr> </table> </div><div class="memdoc"> <p>UClassID is used to identify classes without using the compiler's RTTI. </p> <p>This was used before C++ compilers consistently supported RTTI. ICU 4.6 requires compiler RTTI to be turned on.</p> <p>Each class hierarchy which needs to implement polymorphic clone() or <a class="el" href="namespaceicu.html#a1c2f6ca43e636f38d1a3291eb851e9f0" title="Global operator == for StringPiece.">operator==()</a> defines two methods, described in detail below. UClassID values can be compared using <a class="el" href="namespaceicu.html#a1c2f6ca43e636f38d1a3291eb851e9f0" title="Global operator == for StringPiece.">operator==()</a>. Nothing else should be done with them.</p> <dl class="section user"><dt></dt><dd>In class hierarchies that implement "poor man's RTTI", each concrete subclass implements getDynamicClassID() in the same way:</dd></dl> <div class="fragment"><div class="line"><span class="keyword">class </span>Derived {</div> <div class="line"><span class="keyword">public</span>:</div> <div class="line"> <span class="keyword">virtual</span> <a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a> getDynamicClassID()<span class="keyword"> const</span></div> <div class="line"><span class="keyword"> </span>{ <span class="keywordflow">return</span> Derived::getStaticClassID(); }</div> <div class="line">}</div> </div><!-- fragment --><p>Each concrete class implements getStaticClassID() as well, which allows clients to test for a specific type.</p> <div class="fragment"><div class="line"><span class="keyword">class </span>Derived {</div> <div class="line"><span class="keyword">public</span>:</div> <div class="line"> <span class="keyword">static</span> <a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a> U_EXPORT2 getStaticClassID();</div> <div class="line"><span class="keyword">private</span>:</div> <div class="line"> <span class="keyword">static</span> <span class="keywordtype">char</span> fgClassID;</div> <div class="line">}</div> <div class="line"></div> <div class="line"><span class="comment">// In Derived.cpp:</span></div> <div class="line"><a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a> Derived::getStaticClassID()</div> <div class="line"> { <span class="keywordflow">return</span> (<a class="code" href="uobject_8h.html#a22af10545208a455a6e884008df48e9f" title="UClassID is used to identify classes without using the compiler's RTTI.">UClassID</a>)&Derived::fgClassID; }</div> <div class="line"><span class="keywordtype">char</span> Derived::fgClassID = 0; <span class="comment">// Value is irrelevant</span></div> </div><!-- fragment --> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable002130">Stable:</a></b></dt><dd>ICU 2.0 </dd></dl> <p>Definition at line <a class="el" href="uobject_8h_source.html#l00091">91</a> of file <a class="el" href="uobject_8h_source.html">uobject.h</a>.</p> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Fri Oct 4 2013 14:10:23 for ICU 52.1 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.1.2 </small></address> </body> </html>