<!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.11"/> <title>ICU 58.2: icu::ByteSink 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 id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">ICU 58.2  <span id="projectnumber">58.2</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.11 --> <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 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 id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceicu.html">icu</a></li><li class="navelem"><a class="el" href="classicu_1_1ByteSink.html">ByteSink</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">icu::ByteSink Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div> </div><!--header--> <div class="contents"> <p>A <a class="el" href="classicu_1_1ByteSink.html" title="A ByteSink can be filled with bytes. ">ByteSink</a> can be filled with bytes. <a href="classicu_1_1ByteSink.html#details">More...</a></p> <p><code>#include <<a class="el" href="bytestream_8h_source.html">bytestream.h</a>></code></p> <div class="dynheader"> Inheritance diagram for icu::ByteSink:</div> <div class="dyncontent"> <div class="center"> <img src="classicu_1_1ByteSink.png" usemap="#icu::ByteSink_map" alt=""/> <map id="icu::ByteSink_map" name="icu::ByteSink_map"> <area href="classicu_1_1UMemory.html" title="UMemory is the common ICU base class. " alt="icu::UMemory" shape="rect" coords="107,0,312,24"/> <area href="classicu_1_1CheckedArrayByteSink.html" title="Implementation of ByteSink that writes to a flat byte array, with bounds-checking: This sink will not..." alt="icu::CheckedArrayByteSink" shape="rect" coords="0,112,205,136"/> <area href="classicu_1_1StringByteSink.html" title="Implementation of ByteSink that writes to a "string". " alt="icu::StringByteSink< StringClass >" shape="rect" coords="215,112,420,136"/> </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:ac3e9a257c1fd9e981bceb8f6981d9b6e"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1ByteSink.html#ac3e9a257c1fd9e981bceb8f6981d9b6e">ByteSink</a> ()</td></tr> <tr class="memdesc:ac3e9a257c1fd9e981bceb8f6981d9b6e"><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#ac3e9a257c1fd9e981bceb8f6981d9b6e">More...</a><br /></td></tr> <tr class="separator:ac3e9a257c1fd9e981bceb8f6981d9b6e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aeea90b9a402f4446d493f7e6cc3361c0"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1ByteSink.html#aeea90b9a402f4446d493f7e6cc3361c0">~ByteSink</a> ()</td></tr> <tr class="memdesc:aeea90b9a402f4446d493f7e6cc3361c0"><td class="mdescLeft"> </td><td class="mdescRight">Virtual destructor. <a href="#aeea90b9a402f4446d493f7e6cc3361c0">More...</a><br /></td></tr> <tr class="separator:aeea90b9a402f4446d493f7e6cc3361c0"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a61fe994281322e8a3e3ed2e50c910e41"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41">Append</a> (const char *bytes, int32_t n)=0</td></tr> <tr class="memdesc:a61fe994281322e8a3e3ed2e50c910e41"><td class="mdescLeft"> </td><td class="mdescRight">Append "bytes[0,n-1]" to this. <a href="#a61fe994281322e8a3e3ed2e50c910e41">More...</a><br /></td></tr> <tr class="separator:a61fe994281322e8a3e3ed2e50c910e41"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a391838e3698a0132097ff2877565aaee"><td class="memItemLeft" align="right" valign="top">virtual char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1ByteSink.html#a391838e3698a0132097ff2877565aaee">GetAppendBuffer</a> (int32_t min_capacity, int32_t desired_capacity_hint, char *scratch, int32_t scratch_capacity, int32_t *result_capacity)</td></tr> <tr class="memdesc:a391838e3698a0132097ff2877565aaee"><td class="mdescLeft"> </td><td class="mdescRight">Returns a writable buffer for appending and writes the buffer's capacity to *result_capacity. <a href="#a391838e3698a0132097ff2877565aaee">More...</a><br /></td></tr> <tr class="separator:a391838e3698a0132097ff2877565aaee"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ad8b12cabefa31cfcdd1dc166a9f829f2"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classicu_1_1ByteSink.html#ad8b12cabefa31cfcdd1dc166a9f829f2">Flush</a> ()</td></tr> <tr class="memdesc:ad8b12cabefa31cfcdd1dc166a9f829f2"><td class="mdescLeft"> </td><td class="mdescRight">Flush internal buffers. <a href="#ad8b12cabefa31cfcdd1dc166a9f829f2">More...</a><br /></td></tr> <tr class="separator:ad8b12cabefa31cfcdd1dc166a9f829f2"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>A <a class="el" href="classicu_1_1ByteSink.html" title="A ByteSink can be filled with bytes. ">ByteSink</a> can be filled with bytes. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000051">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> <p>Definition at line <a class="el" href="bytestream_8h_source.html#l00050">50</a> of file <a class="el" href="bytestream_8h_source.html">bytestream.h</a>.</p> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a class="anchor" id="ac3e9a257c1fd9e981bceb8f6981d9b6e"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">icu::ByteSink::ByteSink </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Default constructor. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000054">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> <p>Definition at line <a class="el" href="bytestream_8h_source.html#l00056">56</a> of file <a class="el" href="bytestream_8h_source.html">bytestream.h</a>.</p> </div> </div> <a class="anchor" id="aeea90b9a402f4446d493f7e6cc3361c0"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual icu::ByteSink::~ByteSink </td> <td>(</td> <td class="paramname"></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>Virtual destructor. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000055">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a class="anchor" id="a61fe994281322e8a3e3ed2e50c910e41"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual void icu::ByteSink::Append </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>bytes</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>n</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">pure virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Append "bytes[0,n-1]" to this. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">bytes</td><td>the pointer to the bytes </td></tr> <tr><td class="paramname">n</td><td>the number of bytes; must be non-negative </td></tr> </table> </dd> </dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000056">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> <p>Implemented in <a class="el" href="classicu_1_1StringByteSink.html#a966cbe182b8f5f14682580adbb9f66f9">icu::StringByteSink< StringClass ></a>, and <a class="el" href="classicu_1_1CheckedArrayByteSink.html#aa927725da1eec2f646f7be734d4d4c06">icu::CheckedArrayByteSink</a>.</p> </div> </div> <a class="anchor" id="ad8b12cabefa31cfcdd1dc166a9f829f2"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual void icu::ByteSink::Flush </td> <td>(</td> <td class="paramname"></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>Flush internal buffers. </p> <p>Some byte sinks use internal buffers or provide buffering and require calling <a class="el" href="classicu_1_1ByteSink.html#ad8b12cabefa31cfcdd1dc166a9f829f2" title="Flush internal buffers. ">Flush()</a> at the end of the stream. The <a class="el" href="classicu_1_1ByteSink.html" title="A ByteSink can be filled with bytes. ">ByteSink</a> should be ready for further <a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41" title="Append "bytes[0,n-1]" to this. ">Append()</a> calls after <a class="el" href="classicu_1_1ByteSink.html#ad8b12cabefa31cfcdd1dc166a9f829f2" title="Flush internal buffers. ">Flush()</a>. The default implementation of <a class="el" href="classicu_1_1ByteSink.html#ad8b12cabefa31cfcdd1dc166a9f829f2" title="Flush internal buffers. ">Flush()</a> does nothing. </p><dl class="stable"><dt><b><a class="el" href="stable.html#_stable000058">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> </div> </div> <a class="anchor" id="a391838e3698a0132097ff2877565aaee"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual char* icu::ByteSink::GetAppendBuffer </td> <td>(</td> <td class="paramtype">int32_t </td> <td class="paramname"><em>min_capacity</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>desired_capacity_hint</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char * </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>scratch_capacity</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t * </td> <td class="paramname"><em>result_capacity</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 *result_capacity. </p> <p>Guarantees *result_capacity>=min_capacity. May return a pointer to the caller-owned scratch buffer which must have scratch_capacity>=min_capacity. The returned buffer is only valid until the next operation on this <a class="el" href="classicu_1_1ByteSink.html" title="A ByteSink can be filled with bytes. ">ByteSink</a>.</p> <p>After writing at most *result_capacity bytes, call <a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41" title="Append "bytes[0,n-1]" to this. ">Append()</a> with the pointer returned from this function and the number of bytes written. Many <a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41" title="Append "bytes[0,n-1]" to this. ">Append()</a> implementations will avoid copying bytes if this function returned an internal buffer.</p> <p>Partial usage example: int32_t capacity; char* buffer = sink->GetAppendBuffer(..., &capacity); ... Write n bytes into buffer, with n <= capacity. sink->Append(buffer, n); In many implementations, that call to Append will avoid copying bytes.</p> <p>If the <a class="el" href="classicu_1_1ByteSink.html" title="A ByteSink can be filled with bytes. ">ByteSink</a> allocates or reallocates an internal buffer, it should use the desired_capacity_hint if appropriate. If a caller cannot provide a reasonable guess at the desired capacity, it should pass desired_capacity_hint=0.</p> <p>If a non-scratch buffer is returned, the caller may only pass a prefix to it to <a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41" title="Append "bytes[0,n-1]" to this. ">Append()</a>. That is, it is not correct to pass an interior pointer to <a class="el" href="classicu_1_1ByteSink.html#a61fe994281322e8a3e3ed2e50c910e41" title="Append "bytes[0,n-1]" to this. ">Append()</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">min_capacity</td><td>required minimum capacity of the returned buffer; must be non-negative </td></tr> <tr><td class="paramname">desired_capacity_hint</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">scratch_capacity</td><td>capacity of the scratch buffer </td></tr> <tr><td class="paramname">result_capacity</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 *result_capacity>=min_capacity </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable000057">Stable:</a></b></dt><dd>ICU 4.2 </dd></dl> <p>Reimplemented in <a class="el" href="classicu_1_1CheckedArrayByteSink.html#a20f2bd9b3666a6fcb9782a0015bc6c42">icu::CheckedArrayByteSink</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="bytestream_8h_source.html">bytestream.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.11 </small></address> </body> </html>