blob: c0d3d8db31b80587d7971b079094e2185a9290e5 [file] [log] [blame]
<!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>Boost.Locale: boost::locale::util::base_converter Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="boost-small.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">Boost.Locale
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</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>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('classboost_1_1locale_1_1util_1_1base__converter.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> </div>
<div class="headertitle">
<div class="title">boost::locale::util::base_converter Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<!-- doxytag: class="boost::locale::util::base_converter" -->
<p>This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point.
<a href="classboost_1_1locale_1_1util_1_1base__converter.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="util_8hpp_source.html">boost/locale/util.hpp</a>&gt;</code></p>
<p><a href="classboost_1_1locale_1_1util_1_1base__converter-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">max_len</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">is_thread_safe</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html">base_converter</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a702b31840be6f5c540cd22ac75cb2349">clone</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a27181b314e09f62ae9ea8fcd30d4e7c4">to_unicode</a> (char const *&amp;begin, char const *end)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#afeecf1ee2699c26960cbf2d7d6d71d41">from_unicode</a> (uint32_t u, char *begin, char const *end)</td></tr>
<tr><td colspan="2"><h2><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">illegal</a> = <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb">utf::illegal</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">incomplete</a> = <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">utf::incomplete</a></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point. </p>
<p>This class is used for creation of std::codecvt facet for converting utf-16/utf-32 encoding to encoding supported by this converter</p>
<p>Please note, this converter should be fully stateless. Fully stateless means it should never assume that it is called in any specific order on the text. Even if the encoding itself seems to be stateless like windows-1255 or shift-jis, some encoders (most notably iconv) can actually compose several code-point into one or decompose them in case composite characters are found. So be very careful when implementing these converters for certain character set. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a702b31840be6f5c540cd22ac75cb2349"></a><!-- doxytag: member="boost::locale::util::base_converter::clone" ref="a702b31840be6f5c540cd22ac75cb2349" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html">base_converter</a>* <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a702b31840be6f5c540cd22ac75cb2349">boost::locale::util::base_converter::clone</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const<code> [inline, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Create a polymorphic copy of this object, usually called only if <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">is_thread_safe()</a> return false </p>
</div>
</div>
<a class="anchor" id="afeecf1ee2699c26960cbf2d7d6d71d41"></a><!-- doxytag: member="boost::locale::util::base_converter::from_unicode" ref="afeecf1ee2699c26960cbf2d7d6d71d41" args="(uint32_t u, char *begin, char const *end)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual uint32_t <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#afeecf1ee2699c26960cbf2d7d6d71d41">boost::locale::util::base_converter::from_unicode</a> </td>
<td>(</td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>u</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&#160;</td>
<td class="paramname"><em>begin</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char const *&#160;</td>
<td class="paramname"><em>end</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [inline, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Convert a single code-point <em>u</em> into encoding and store it in [begin,end) range.</p>
<p>If u is invalid Unicode code-point, or it can not be mapped correctly to represented character set, <em>illegal</em> should be returned</p>
<p>If u can be converted to a sequence of bytes c1, ... , cN (1&lt;= N &lt;= <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">max_len()</a> ) then</p>
<ol type="1">
<li>If end - begin &gt;= N, c1, ... cN are written starting at begin and N is returned</li>
<li>If end - begin &lt; N, incomplete is returned, it is unspecified what would be stored in bytes in range [begin,end) </li>
</ol>
</div>
</div>
<a class="anchor" id="aadcc2c1a767f9d24972c6995e81c1315"></a><!-- doxytag: member="boost::locale::util::base_converter::is_thread_safe" ref="aadcc2c1a767f9d24972c6995e81c1315" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual bool <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">boost::locale::util::base_converter::is_thread_safe</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const<code> [inline, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns true if calling the functions from_unicode, to_unicode, and max_len is thread safe.</p>
<p>Rule of thumb: if this class' implementation uses simple tables that are unchanged or is purely algorithmic like UTF-8 - so it does not share any mutable bit for independent to_unicode, from_unicode calls, you may set it to true, otherwise, for example if you use iconv_t descriptor or UConverter as conversion object return false, and this object will be cloned for each use. </p>
</div>
</div>
<a class="anchor" id="ab2332b78e3e0c0b94ea3f6dafd123d60"></a><!-- doxytag: member="boost::locale::util::base_converter::max_len" ref="ab2332b78e3e0c0b94ea3f6dafd123d60" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual int <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">boost::locale::util::base_converter::max_len</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const<code> [inline, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the maximal length that one Unicode code-point can be converted to, for example for UTF-8 it is 4, for Shift-JIS it is 2 and ISO-8859-1 is 1 </p>
</div>
</div>
<a class="anchor" id="a27181b314e09f62ae9ea8fcd30d4e7c4"></a><!-- doxytag: member="boost::locale::util::base_converter::to_unicode" ref="a27181b314e09f62ae9ea8fcd30d4e7c4" args="(char const *&amp;begin, char const *end)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual uint32_t <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a27181b314e09f62ae9ea8fcd30d4e7c4">boost::locale::util::base_converter::to_unicode</a> </td>
<td>(</td>
<td class="paramtype">char const *&amp;&#160;</td>
<td class="paramname"><em>begin</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char const *&#160;</td>
<td class="paramname"><em>end</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [inline, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Convert a single character starting at begin and ending at most at end to Unicode code-point.</p>
<p>if valid input sequence found in [<em>begin</em>,<em>code_point_end</em>) such as <em>begin</em> &lt; <em>code_point_end</em> &amp;&amp; <em>code_point_end</em> &lt;= <em>end</em> it is converted to its Unicode code point equivalent, <em>begin</em> is set to <em>code_point_end</em> </p>
<p>if incomplete input sequence found in [<em>begin</em>,<em>end</em>), i.e. there my be such <em>code_point_end</em> that <em>code_point_end</em> &gt; <em>end</em> and [<em>begin</em>, <em>code_point_end</em>) would be valid input sequence, then <em>incomplete</em> is returned begin stays unchanged, for example for UTF-8 conversion a *begin = 0xc2, <em>begin</em> +1 = <em>end</em> is such situation.</p>
<p>if invalid input sequence found, i.e. there is a sequence [<em>begin</em>, <em>code_point_end</em>) such as <em>code_point_end</em> &lt;= <em>end</em> that is illegal for this encoding, <em>illegal</em> is returned and begin stays unchanged. For example if *begin = 0xFF and begin &lt; end for UTF-8, then <em>illegal</em> is returned. </p>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="aa02e2dfd8ddc2b40a8705c6ea7fa8d48"></a><!-- doxytag: member="boost::locale::util::base_converter::illegal" ref="aa02e2dfd8ddc2b40a8705c6ea7fa8d48" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const uint32_t <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">boost::locale::util::base_converter::illegal</a> = <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb">utf::illegal</a><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>This value should be returned when an illegal input sequence or code-point is observed: For example if a UCS-32 code-point is in the range reserved for UTF-16 surrogates or an invalid UTF-8 sequence is found </p>
</div>
</div>
<a class="anchor" id="aa78dd2bae2783e31a00849a4e74aeb1e"></a><!-- doxytag: member="boost::locale::util::base_converter::incomplete" ref="aa78dd2bae2783e31a00849a4e74aeb1e" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const uint32_t <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">boost::locale::util::base_converter::incomplete</a> = <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">utf::incomplete</a><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>This value is returned in following cases: The of incomplete input sequence was found or insufficient output buffer was provided so complete output could not be written. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>boost/locale/<a class="el" href="util_8hpp_source.html">util.hpp</a></li>
</ul>
</div><!-- contents -->
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><b>boost</b> </li>
<li class="navelem"><a class="el" href="namespaceboost_1_1locale.html">locale</a> </li>
<li class="navelem"><a class="el" href="namespaceboost_1_1locale_1_1util.html">util</a> </li>
<li class="navelem"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html">base_converter</a> </li>
<li class="footer">
&copy; Copyright 2009-2012 Artyom Beilis, Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>, Version 1.0.
</li>
</ul>
</div>
</body>
</html>