]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/locale/doc/html/classboost_1_1locale_1_1generic__codecvt.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / locale / doc / html / classboost_1_1locale_1_1generic__codecvt.html
CommitLineData
7c673cae
FG
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6<meta name="generator" content="Doxygen 1.8.6"/>
7<title>Boost.Locale: boost::locale::generic_codecvt&lt; CharType, CodecvtImpl, CharSize &gt; Class Template Reference</title>
8<link href="tabs.css" rel="stylesheet" type="text/css"/>
9<script type="text/javascript" src="jquery.js"></script>
10<script type="text/javascript" src="dynsections.js"></script>
11<link href="navtree.css" rel="stylesheet" type="text/css"/>
12<script type="text/javascript" src="resize.js"></script>
13<script type="text/javascript" src="navtree.js"></script>
14<script type="text/javascript">
15 $(document).ready(initResizable);
16 $(window).load(resizeHeight);
17</script>
18<link href="doxygen.css" rel="stylesheet" type="text/css" />
19</head>
20<body>
21<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
22<div id="titlearea">
23<table cellspacing="0" cellpadding="0">
24 <tbody>
25 <tr style="height: 56px;">
26 <td id="projectlogo"><img alt="Logo" src="boost-small.png"/></td>
27 <td style="padding-left: 0.5em;">
28 <div id="projectname">Boost.Locale
29 </div>
30 </td>
31 </tr>
32 </tbody>
33</table>
34</div>
35<!-- end header part -->
36<!-- Generated by Doxygen 1.8.6 -->
37 <div id="navrow1" class="tabs">
38 <ul class="tablist">
39 <li><a href="index.html"><span>Main&#160;Page</span></a></li>
40 <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
41 <li><a href="modules.html"><span>Modules</span></a></li>
42 <li><a href="namespaces.html"><span>Namespaces</span></a></li>
43 <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
44 <li><a href="files.html"><span>Files</span></a></li>
45 <li><a href="examples.html"><span>Examples</span></a></li>
46 </ul>
47 </div>
48 <div id="navrow2" class="tabs2">
49 <ul class="tablist">
50 <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
51 <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
52 <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
53 </ul>
54 </div>
55</div><!-- top -->
56<div id="side-nav" class="ui-resizable side-nav-resizable">
57 <div id="nav-tree">
58 <div id="nav-tree-contents">
59 <div id="nav-sync" class="sync"></div>
60 </div>
61 </div>
62 <div id="splitbar" style="-moz-user-select:none;"
63 class="ui-resizable-handle">
64 </div>
65</div>
66<script type="text/javascript">
67$(document).ready(function(){initNavTree('classboost_1_1locale_1_1generic__codecvt.html','');});
68</script>
69<div id="doc-content">
70<div class="header">
71 <div class="headertitle">
72<div class="title">boost::locale::generic_codecvt&lt; CharType, CodecvtImpl, CharSize &gt; Class Template Reference</div> </div>
73</div><!--header-->
74<div class="contents">
75
76<p>Geneneric generic codecvt facet, various stateless encodings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t.
77 <a href="classboost_1_1locale_1_1generic__codecvt.html#details">More...</a></p>
78
79<p><code>#include &lt;<a class="el" href="generic__codecvt_8hpp_source.html">boost/locale/generic_codecvt.hpp</a>&gt;</code></p>
80<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
81<div class="textblock"><h3>template&lt;typename CharType, typename CodecvtImpl, int CharSize = sizeof(CharType)&gt;<br/>
82class boost::locale::generic_codecvt&lt; CharType, CodecvtImpl, CharSize &gt;</h3>
83
84<p>Geneneric generic codecvt facet, various stateless encodings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t. </p>
85<p>Implementations should dervide from this class defining itself as CodecvtImpl and provide following members</p>
86<ul>
87<li><code>state_type</code> - a type of special object that allows to store intermediate cached data, for example <code>iconv_t</code> descriptor</li>
88<li><code>state_type initial_state(generic_codecvt_base::initial_convertion_state direction) const</code> - member function that creates initial state</li>
89<li><code>int max_encoding_length() const</code> - a maximal length that one Unicode code point is represented, for UTF-8 for example it is 4 from ISO-8859-1 it is 1</li>
90<li><code><a class="el" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8" title="The integral type that can hold a Unicode code point. ">utf::code_point</a> to_unicode(state_type &amp;state,char const *&amp;begin,char const *end)</code> - extract first code point from the text in range [begin,end), in case of success begin would point to the next character sequence to be encoded to next code point, in case of incomplete sequence - <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38" title="Special constant that defines incomplete code point. ">utf::incomplete</a> shell be returned, and in case of invalid input sequence <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb" title="Special constant that defines illegal code point. ">utf::illegal</a> shell be returned and begin would remain unmodified</li>
91<li><code><a class="el" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8" title="The integral type that can hold a Unicode code point. ">utf::code_point</a> from_unicode(state_type &amp;state,utf::code_point u,char *begin,char const *end)</code> - convert a unicode code point <code>u</code> into a character seqnece at [begin,end). Return the length of the sequence in case of success, <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38" title="Special constant that defines incomplete code point. ">utf::incomplete</a> in case of not enough room to encode the code point of <a class="el" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb" title="Special constant that defines illegal code point. ">utf::illegal</a> in case conversion can not be performed</li>
92</ul>
93<p>For example implementaion of codecvt for latin1/ISO-8859-1 character set</p>
94<div class="fragment"><div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt;</div>
95<div class="line"><span class="keyword">class </span>latin1_codecvt :<a class="code" href="classboost_1_1locale_1_1generic__codecvt.html">boost::locale::generic_codecvt</a>&lt;CharType,latin1_codecvt&lt;CharType&gt; &gt; </div>
96<div class="line">{</div>
97<div class="line"><span class="keyword">public</span>:</div>
98<div class="line"> </div>
99<div class="line"> <span class="comment">/* Standard codecvt constructor */</span> </div>
100<div class="line"> latin1_codecvt(<span class="keywordtype">size_t</span> refs = 0) : boost::locale::generic_codecvt&lt;CharType,latin1_codecvt&lt;CharType&gt; &gt;(refs) </div>
101<div class="line"> {</div>
102<div class="line"> }</div>
103<div class="line"></div>
104<div class="line"> <span class="comment">/* State is unused but required by generic_codecvt */</span></div>
105<div class="line"> <span class="keyword">struct </span>state_type {};</div>
106<div class="line"></div>
107<div class="line"> state_type initial_state(<a class="code" href="classboost_1_1locale_1_1generic__codecvt__base.html#af28c4b64af6cbf2eb01c444e2cdf08c3">generic_codecvt_base::initial_convertion_state</a> <span class="comment">/*unused*/</span>)<span class="keyword"> const</span></div>
108<div class="line"><span class="keyword"> </span>{</div>
109<div class="line"> <span class="keywordflow">return</span> state_type();</div>
110<div class="line"> }</div>
111<div class="line"> </div>
112<div class="line"> <span class="keywordtype">int</span> max_encoding_length()<span class="keyword"> const</span></div>
113<div class="line"><span class="keyword"> </span>{</div>
114<div class="line"> <span class="keywordflow">return</span> 1;</div>
115<div class="line"> }</div>
116<div class="line"></div>
117<div class="line"> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a> to_unicode(state_type &amp;,<span class="keywordtype">char</span> <span class="keyword">const</span> *&amp;begin,<span class="keywordtype">char</span> <span class="keyword">const</span> *end)<span class="keyword"> const</span></div>
118<div class="line"><span class="keyword"> </span>{</div>
119<div class="line"> <span class="keywordflow">if</span>(begin == end)</div>
120<div class="line"> <span class="keywordflow">return</span> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">boost::locale::utf::incomplete</a>;</div>
121<div class="line"> <span class="keywordflow">return</span> *begin++; </div>
122<div class="line"> }</div>
123<div class="line"></div>
124<div class="line"> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a> from_unicode(state_type &amp;,<a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a> u,<span class="keywordtype">char</span> *begin,<span class="keywordtype">char</span> <span class="keyword">const</span> *end)<span class="keyword"> const</span></div>
125<div class="line"><span class="keyword"> </span>{</div>
126<div class="line"> <span class="keywordflow">if</span>(u &gt;= 256)</div>
127<div class="line"> <span class="keywordflow">return</span> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb">boost::locale::utf::illegal</a>;</div>
128<div class="line"> <span class="keywordflow">if</span>(begin == end)</div>
129<div class="line"> <span class="keywordflow">return</span> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">boost::locale::utf::incomplete</a>;</div>
130<div class="line"> *begin = u;</div>
131<div class="line"> <span class="keywordflow">return</span> 1; </div>
132<div class="line"> }</div>
133<div class="line">};</div>
134</div><!-- fragment --><p>When external tools used for encoding conversion, the <code>state_type</code> is useful to save objects used for conversions. For example, icu::UConverter can be saved in such a state for an efficient use:</p>
135<div class="fragment"><div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt;</div>
136<div class="line"><span class="keyword">class </span>icu_codecvt :<a class="code" href="classboost_1_1locale_1_1generic__codecvt.html">boost::locale::generic_codecvt</a>&lt;CharType,icu_codecvt&lt;CharType&gt; &gt; </div>
137<div class="line">{</div>
138<div class="line"><span class="keyword">public</span>:</div>
139<div class="line"> </div>
140<div class="line"> <span class="comment">/* Standard codecvt constructor */</span> </div>
141<div class="line"> icu_codecvt(std::string <span class="keyword">const</span> &amp;name,refs = 0) : </div>
142<div class="line"> boost::locale::generic_codecvt&lt;CharType,latin1_codecvt&lt;CharType&gt; &gt;(refs)</div>
143<div class="line"> { ... }</div>
144<div class="line"></div>
145<div class="line"> <span class="comment">/* State is unused but required by generic_codecvt */</span></div>
146<div class="line"> <span class="keyword">struct </span>std::unique_ptr&lt;UConverter,void (*)(UConverter*)&gt; state_type;</div>
147<div class="line"></div>
148<div class="line"> state_type &amp;&amp;initial_state(<a class="code" href="classboost_1_1locale_1_1generic__codecvt__base.html#af28c4b64af6cbf2eb01c444e2cdf08c3">generic_codecvt_base::initial_convertion_state</a> <span class="comment">/*unused*/</span>)<span class="keyword"> const</span></div>
149<div class="line"><span class="keyword"> </span>{</div>
150<div class="line"> UErrorCode err = U_ZERO_ERROR;</div>
151<div class="line"> state_type ptr(ucnv_safeClone(converter_,0,0,&amp;err,ucnv_close);</div>
152<div class="line"> <span class="keywordflow">return</span> std::move(ptr);</div>
153<div class="line"> }</div>
154<div class="line"> </div>
155<div class="line"> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a> to_unicode(state_type &amp;ptr,<span class="keywordtype">char</span> <span class="keyword">const</span> *&amp;begin,<span class="keywordtype">char</span> <span class="keyword">const</span> *end)<span class="keyword"> const</span></div>
156<div class="line"><span class="keyword"> </span>{</div>
157<div class="line"> UErrorCode err = U_ZERO_ERROR;</div>
158<div class="line"> <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a> cp = ucnv_getNextUChar(ptr.get(),&amp;begin,end,&amp;err);</div>
159<div class="line"> ...</div>
160<div class="line"> }</div>
161<div class="line"> ...</div>
162<div class="line">};</div>
163</div><!-- fragment --> </div><hr/>The documentation for this class was generated from the following file:<ul>
164<li>boost/locale/<a class="el" href="generic__codecvt_8hpp_source.html">generic_codecvt.hpp</a></li>
165</ul>
166</div><!-- contents -->
167</div><!-- doc-content -->
168
169 <li class="footer">
170&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.
171 </li>
172 </ul>
173 </div>
174</body>
175</html>