<!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"/> <meta name="generator" content="Doxygen 1.8.3.1"/> <title>ICU 49.1.1: Appendable Class 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 49.1.1  <span id="projectnumber">49.1.1</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3.1 --> <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 class="current"><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="classes.html"><span>Data Structure Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Data Fields</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Appendable Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div> </div><!--header--> <div class="contents"> <p>Base class for objects to which Unicode characters and strings can be appended. <a href="classAppendable.html#details">More...</a></p> <p><code>#include <<a class="el" href="appendable_8h_source.html">appendable.h</a>></code></p> <div class="dynheader"> Inheritance diagram for Appendable:</div> <div class="dyncontent"> <div class="center"> <img src="classAppendable.png" usemap="#Appendable_map" alt=""/> <map id="Appendable_map" name="Appendable_map"> <area href="classUObject.html" title="UObject is the common ICU "boilerplate" class." alt="UObject" shape="rect" coords="0,56,159,80"/> <area href="classUMemory.html" title="UMemory is the common ICU base class." alt="UMemory" shape="rect" coords="0,0,159,24"/> <area href="classUnicodeStringAppendable.html" title="An Appendable implementation which writes to a UnicodeString." alt="UnicodeStringAppendable" shape="rect" coords="0,168,159,192"/> </map> </div></div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:aa7fad522ea3fcc31d9523a1f19751f89"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#aa7fad522ea3fcc31d9523a1f19751f89">~Appendable</a> ()</td></tr> <tr class="memdesc:aa7fad522ea3fcc31d9523a1f19751f89"><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#aa7fad522ea3fcc31d9523a1f19751f89">More...</a><br/></td></tr> <tr class="separator:aa7fad522ea3fcc31d9523a1f19751f89"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5e9851386b9f3b63e750d4d31149f023"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#a5e9851386b9f3b63e750d4d31149f023">appendCodeUnit</a> (<a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> c)=0</td></tr> <tr class="memdesc:a5e9851386b9f3b63e750d4d31149f023"><td class="mdescLeft"> </td><td class="mdescRight">Appends a 16-bit code unit. <a href="#a5e9851386b9f3b63e750d4d31149f023">More...</a><br/></td></tr> <tr class="separator:a5e9851386b9f3b63e750d4d31149f023"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5292cdc7ee62dc99a9ac58fecfbba9b5"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#a5292cdc7ee62dc99a9ac58fecfbba9b5">appendCodePoint</a> (<a class="el" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809">UChar32</a> c)</td></tr> <tr class="memdesc:a5292cdc7ee62dc99a9ac58fecfbba9b5"><td class="mdescLeft"> </td><td class="mdescRight">Appends a code point. <a href="#a5292cdc7ee62dc99a9ac58fecfbba9b5">More...</a><br/></td></tr> <tr class="separator:a5292cdc7ee62dc99a9ac58fecfbba9b5"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5edf68de9d036d3bcf1cac6d3131c933"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#a5edf68de9d036d3bcf1cac6d3131c933">appendString</a> (const <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> *s, int32_t length)</td></tr> <tr class="memdesc:a5edf68de9d036d3bcf1cac6d3131c933"><td class="mdescLeft"> </td><td class="mdescRight">Appends a string. <a href="#a5edf68de9d036d3bcf1cac6d3131c933">More...</a><br/></td></tr> <tr class="separator:a5edf68de9d036d3bcf1cac6d3131c933"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ad6db9e7d1a842f22d0b03882719204d5"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#ad6db9e7d1a842f22d0b03882719204d5">reserveAppendCapacity</a> (int32_t appendCapacity)</td></tr> <tr class="memdesc:ad6db9e7d1a842f22d0b03882719204d5"><td class="mdescLeft"> </td><td class="mdescRight">Tells the object that the caller is going to append roughly appendCapacity UChars. <a href="#ad6db9e7d1a842f22d0b03882719204d5">More...</a><br/></td></tr> <tr class="separator:ad6db9e7d1a842f22d0b03882719204d5"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ace1dc7b1d182e77f31932c6f99d6cd6a"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classAppendable.html#ace1dc7b1d182e77f31932c6f99d6cd6a">getAppendBuffer</a> (int32_t minCapacity, int32_t desiredCapacityHint, <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> *scratch, int32_t scratchCapacity, int32_t *resultCapacity)</td></tr> <tr class="memdesc:ace1dc7b1d182e77f31932c6f99d6cd6a"><td class="mdescLeft"> </td><td class="mdescRight">Returns a writable buffer for appending and writes the buffer's capacity to *resultCapacity. <a href="#ace1dc7b1d182e77f31932c6f99d6cd6a">More...</a><br/></td></tr> <tr class="separator:ace1dc7b1d182e77f31932c6f99d6cd6a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="inherit_header pub_methods_classUObject"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classUObject')"><img src="closed.png" alt="-"/> Public Member Functions inherited from <a class="el" href="classUObject.html">UObject</a></td></tr> <tr class="memitem:ace22cf29a90641ef43350deae5bedb85 inherit pub_methods_classUObject"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classUObject.html#ace22cf29a90641ef43350deae5bedb85">~UObject</a> ()</td></tr> <tr class="memdesc:ace22cf29a90641ef43350deae5bedb85 inherit pub_methods_classUObject"><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#ace22cf29a90641ef43350deae5bedb85">More...</a><br/></td></tr> <tr class="separator:ace22cf29a90641ef43350deae5bedb85 inherit pub_methods_classUObject"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Base class for objects to which Unicode characters and strings can be appended. </p> <p>Combines elements of Java <a class="el" href="classAppendable.html" title="Base class for objects to which Unicode characters and strings can be appended.">Appendable</a> and ICU4C <a class="el" href="classByteSink.html" title="A ByteSink can be filled with bytes.">ByteSink</a>.</p> <p>This class can be used in APIs where it does not matter whether the actual destination is a <a class="el" href="classUnicodeString.html" title="UnicodeString is a string class that stores Unicode characters directly and provides similar function...">UnicodeString</a>, a UChar[] array, a <a class="el" href="classUnicodeSet.html" title="A mutable set of Unicode characters and multicharacter strings.">UnicodeSet</a>, or any other object that receives and processes characters and/or strings.</p> <p>Implementation classes must implement at least <a class="el" href="classAppendable.html#a5e9851386b9f3b63e750d4d31149f023" title="Appends a 16-bit code unit.">appendCodeUnit(UChar)</a>. The base class provides default implementations for the other methods.</p> <p>The methods do not take UErrorCode parameters. If an error occurs (e.g., out-of-memory), in addition to returning FALSE from failing operations, the implementation must prevent unexpected behavior (e.g., crashes) from further calls and should make the error condition available separately (e.g., store a UErrorCode, make/keep a <a class="el" href="classUnicodeString.html" title="UnicodeString is a string class that stores Unicode characters directly and provides similar function...">UnicodeString</a> bogus). </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000010">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Definition at line <a class="el" href="appendable_8h_source.html#l00049">49</a> of file <a class="el" href="appendable_8h_source.html">appendable.h</a>.</p> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a class="anchor" id="aa7fad522ea3fcc31d9523a1f19751f89"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Appendable::~Appendable </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Destructor. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000012">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a class="anchor" id="a5292cdc7ee62dc99a9ac58fecfbba9b5"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> Appendable::appendCodePoint </td> <td>(</td> <td class="paramtype"><a class="el" href="umachine_8h.html#a09fff5c3b5a5b015324dc3ec3cf92809">UChar32</a> </td> <td class="paramname"><em>c</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Appends a code point. </p> <p>The default implementation calls <a class="el" href="classAppendable.html#a5e9851386b9f3b63e750d4d31149f023" title="Appends a 16-bit code unit.">appendCodeUnit(UChar)</a> once or twice. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">c</td><td>code point 0..0x10ffff </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the operation succeeded </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000014">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Reimplemented in <a class="el" href="classUnicodeStringAppendable.html#a26befc8629e1c015d56ca25eccb54148">UnicodeStringAppendable</a>.</p> </div> </div> <a class="anchor" id="a5e9851386b9f3b63e750d4d31149f023"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> Appendable::appendCodeUnit </td> <td>(</td> <td class="paramtype"><a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> </td> <td class="paramname"><em>c</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">pure virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Appends a 16-bit code unit. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">c</td><td>code unit </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the operation succeeded </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000013">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Implemented in <a class="el" href="classUnicodeStringAppendable.html#acb282259414852552a876814e530ae76">UnicodeStringAppendable</a>.</p> </div> </div> <a class="anchor" id="a5edf68de9d036d3bcf1cac6d3131c933"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> Appendable::appendString </td> <td>(</td> <td class="paramtype">const <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> * </td> <td class="paramname"><em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>length</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Appends a string. </p> <p>The default implementation calls <a class="el" href="classAppendable.html#a5e9851386b9f3b63e750d4d31149f023" title="Appends a 16-bit code unit.">appendCodeUnit(UChar)</a> for each code unit. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>string, must not be NULL if length!=0 </td></tr> <tr><td class="paramname">length</td><td>string length, or -1 if NUL-terminated </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the operation succeeded </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000015">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Reimplemented in <a class="el" href="classUnicodeStringAppendable.html#a84caac9ce2e592c17526f79821bf2e55">UnicodeStringAppendable</a>.</p> </div> </div> <a class="anchor" id="ace1dc7b1d182e77f31932c6f99d6cd6a"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a>* Appendable::getAppendBuffer </td> <td>(</td> <td class="paramtype">int32_t </td> <td class="paramname"><em>minCapacity</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>desiredCapacityHint</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> * </td> <td class="paramname"><em>scratch</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>scratchCapacity</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t * </td> <td class="paramname"><em>resultCapacity</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Returns a writable buffer for appending and writes the buffer's capacity to *resultCapacity. </p> <p>Guarantees *resultCapacity>=minCapacity. May return a pointer to the caller-owned scratch buffer which must have scratchCapacity>=minCapacity. The returned buffer is only valid until the next operation on this <a class="el" href="classAppendable.html" title="Base class for objects to which Unicode characters and strings can be appended.">Appendable</a>.</p> <p>After writing at most *resultCapacity UChars, call <a class="el" href="classAppendable.html#a5edf68de9d036d3bcf1cac6d3131c933" title="Appends a string.">appendString()</a> with the pointer returned from this function and the number of UChars written. Many <a class="el" href="classAppendable.html#a5edf68de9d036d3bcf1cac6d3131c933" title="Appends a string.">appendString()</a> implementations will avoid copying UChars if this function returned an internal buffer.</p> <p>Partial usage example: </p> <div class="fragment"><div class="line">int32_t capacity;</div> <div class="line"><a class="code" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac" title="Define UChar to be char16_t, if available, or wchar_t if that is 16 bits wide; always assumed to be u...">UChar</a>* buffer = app.getAppendBuffer(..., &capacity);</div> <div class="line">... Write n UChars into buffer, with n <= capacity.</div> <div class="line">app.appendString(buffer, n);</div> </div><!-- fragment --><p> In many implementations, that call to append will avoid copying UChars.</p> <p>If the <a class="el" href="classAppendable.html" title="Base class for objects to which Unicode characters and strings can be appended.">Appendable</a> allocates or reallocates an internal buffer, it should use the desiredCapacityHint if appropriate. If a caller cannot provide a reasonable guess at the desired capacity, it should pass desiredCapacityHint=0.</p> <p>If a non-scratch buffer is returned, the caller may only pass a prefix to it to <a class="el" href="classAppendable.html#a5edf68de9d036d3bcf1cac6d3131c933" title="Appends a string.">appendString()</a>. That is, it is not correct to pass an interior pointer to <a class="el" href="classAppendable.html#a5edf68de9d036d3bcf1cac6d3131c933" title="Appends a string.">appendString()</a>.</p> <p>The default implementation always returns the scratch buffer.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">minCapacity</td><td>required minimum capacity of the returned buffer; must be non-negative </td></tr> <tr><td class="paramname">desiredCapacityHint</td><td>desired capacity of the returned buffer; must be non-negative </td></tr> <tr><td class="paramname">scratch</td><td>default caller-owned buffer </td></tr> <tr><td class="paramname">scratchCapacity</td><td>capacity of the scratch buffer </td></tr> <tr><td class="paramname">resultCapacity</td><td>pointer to an integer which will be set to the capacity of the returned buffer </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a buffer with *resultCapacity>=minCapacity </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000017">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Reimplemented in <a class="el" href="classUnicodeStringAppendable.html#ad99a80e66648f44fb12c9a6c7a3aeeed">UnicodeStringAppendable</a>.</p> </div> </div> <a class="anchor" id="ad6db9e7d1a842f22d0b03882719204d5"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual <a class="el" href="umachine_8h.html#a349ef00011f20ccd1d3b424445681aa5">UBool</a> Appendable::reserveAppendCapacity </td> <td>(</td> <td class="paramtype">int32_t </td> <td class="paramname"><em>appendCapacity</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Tells the object that the caller is going to append roughly appendCapacity UChars. </p> <p>A subclass might use this to pre-allocate a larger buffer if necessary. The default implementation does nothing. (It always returns TRUE.) </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">appendCapacity</td><td>estimated number of UChars that will be appended </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the operation succeeded </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000016">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Reimplemented in <a class="el" href="classUnicodeStringAppendable.html#af01525d2244ebf0d19e9f440d69d1c44">UnicodeStringAppendable</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="appendable_8h_source.html">appendable.h</a></li> </ul> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.3.1 </small></address> </body> </html>