2
0
mirror of https://github.com/boostorg/locale.git synced 2026-02-26 16:52:26 +00:00
Files
locale/doc/html/util_8hpp_source.html
Artyom Beilis 48ff4519b8 - Updates according to library requirements
- cleanup of inspect warnings
  - various requiremets like libraries.htm and maintainers.txt


[SVN r73786]
2011-08-15 19:04:34 +00:00

157 lines
14 KiB
HTML

<!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"/>
<title>Boost.Locale: boost/locale/util.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../style/section-basic.css">
</head>
<body>
<div id="boost-common-heading-doc">
<div class="heading-inner">
<div class="heading-placard"></div>
<h1 class="heading-title">
<a href="http://www.boost.org/">
<img src="../style/space.png" alt= "Boost C++ Libraries" class="heading-logo" />
<span class="heading-boost">Boost</span>
<span class="heading-cpplibraries">C++ Libraries</span>
</a>
</h1>
<p class="heading-quote">
<q>...one of the most highly
regarded and expertly designed C++ library projects in the
world.</q>
<span class="heading-attribution">&mdash; <a href=
"http://www.gotw.ca/" class="external">Herb Sutter</a> and <a href=
"http://en.wikipedia.org/wiki/Andrei_Alexandrescu" class="external">Andrei
Alexandrescu</a>, <a href=
"http://safari.awprofessional.com/?XmlId=0321113586" class="external">C++
Coding Standards</a></span>
</p>
</div>
</div>
<div id="boost-common-heading-doc-spacer"></div>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="main.html"><span>Main&nbsp;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><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>boost/locale/util.hpp</h1> </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
<a name="l00002"></a>00002 <span class="comment">// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Distributed under the Boost Software License, Version 1.0. (See</span>
<a name="l00005"></a>00005 <span class="comment">// accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00006"></a>00006 <span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef BOOST_LOCALE_UTIL_HPP</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_LOCALE_UTIL_HPP</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#include &lt;locale&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;typeinfo&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;boost/cstdint.hpp&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;boost/locale/utf.hpp&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;boost/locale/generator.hpp&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;boost/assert.hpp&gt;</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00018"></a>00018 <span class="keyword">namespace </span>boost {
<a name="l00019"></a>00019 <span class="keyword">namespace </span>locale {
<a name="l00024"></a><a class="code" href="namespaceboost_1_1locale_1_1util.html">00024</a> <span class="keyword">namespace </span>util {
<a name="l00025"></a>00025
<a name="l00039"></a>00039 BOOST_LOCALE_DECL
<a name="l00040"></a>00040 std::string <a class="code" href="namespaceboost_1_1locale_1_1util.html#ad9737569d0e2d6b08885b01aba308365" title="Return default system locale name in POSIX format.">get_system_locale</a>(<span class="keywordtype">bool</span> use_utf8_on_windows = <span class="keyword">false</span>);
<a name="l00041"></a>00041
<a name="l00059"></a>00059 BOOST_LOCALE_DECL
<a name="l00060"></a>00060 std::locale <a class="code" href="namespaceboost_1_1locale_1_1util.html#a8322299021a4af3cdbb8b31e775e77f4" title="Installs information facet to locale in based on locale name name.">create_info</a>(std::locale <span class="keyword">const</span> &amp;in,std::string <span class="keyword">const</span> &amp;name);
<a name="l00061"></a>00061
<a name="l00062"></a>00062
<a name="l00077"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html">00077</a> <span class="keyword">class </span><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html" title="This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...">base_converter</a> {
<a name="l00078"></a>00078 <span class="keyword">public</span>:
<a name="l00079"></a>00079
<a name="l00085"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">00085</a> <span class="keyword">static</span> <span class="keyword">const</span> uint32_t <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">illegal</a>=<a class="code" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb" title="Special constant that defines illegal code point.">utf::illegal</a>;
<a name="l00086"></a>00086
<a name="l00091"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">00091</a> <span class="keyword">static</span> <span class="keyword">const</span> uint32_t <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">incomplete</a>=<a class="code" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38" title="Special constant that defines incomplete code point.">utf::incomplete</a>;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keyword">virtual</span> ~<a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html" title="This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...">base_converter</a>()
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 }
<a name="l00100"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">00100</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">max_len</a>()<span class="keyword"> const </span>
<a name="l00101"></a>00101 <span class="keyword"> </span>{
<a name="l00102"></a>00102 <span class="keywordflow">return</span> 1;
<a name="l00103"></a>00103 }
<a name="l00113"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">00113</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">is_thread_safe</a>()<span class="keyword"> const </span>
<a name="l00114"></a>00114 <span class="keyword"> </span>{
<a name="l00115"></a>00115 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00116"></a>00116 }
<a name="l00120"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#a702b31840be6f5c540cd22ac75cb2349">00120</a> <span class="keyword">virtual</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html" title="This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...">base_converter</a> *<a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#a702b31840be6f5c540cd22ac75cb2349">clone</a>()<span class="keyword"> const </span>
<a name="l00121"></a>00121 <span class="keyword"> </span>{
<a name="l00122"></a>00122 BOOST_ASSERT(<span class="keyword">typeid</span>(*<span class="keyword">this</span>)==<span class="keyword">typeid</span>(<a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html" title="This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...">base_converter</a>));
<a name="l00123"></a>00123 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html" title="This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point...">base_converter</a>();
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125
<a name="l00141"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#a27181b314e09f62ae9ea8fcd30d4e7c4">00141</a> <span class="keyword">virtual</span> uint32_t <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#a27181b314e09f62ae9ea8fcd30d4e7c4">to_unicode</a>(<span class="keywordtype">char</span> <span class="keyword">const</span> *&amp;begin,<span class="keywordtype">char</span> <span class="keyword">const</span> *end)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143 <span class="keywordflow">if</span>(begin == end)
<a name="l00144"></a>00144 <span class="keywordflow">return</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">incomplete</a>;
<a name="l00145"></a>00145 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> cp = *begin;
<a name="l00146"></a>00146 <span class="keywordflow">if</span>(cp &lt;= 0x7F) {
<a name="l00147"></a>00147 begin++;
<a name="l00148"></a>00148 <span class="keywordflow">return</span> cp;
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150 <span class="keywordflow">return</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">illegal</a>;
<a name="l00151"></a>00151 }
<a name="l00163"></a>00163
<a name="l00164"></a><a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#afeecf1ee2699c26960cbf2d7d6d71d41">00164</a> <span class="keyword">virtual</span> uint32_t <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#afeecf1ee2699c26960cbf2d7d6d71d41">from_unicode</a>(uint32_t u,<span class="keywordtype">char</span> *begin,<span class="keywordtype">char</span> <span class="keyword">const</span> *end)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 <span class="keywordflow">if</span>(begin==end)
<a name="l00167"></a>00167 <span class="keywordflow">return</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">incomplete</a>;
<a name="l00168"></a>00168 <span class="keywordflow">if</span>(u &gt;= 0x80)
<a name="l00169"></a>00169 <span class="keywordflow">return</span> <a class="code" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">illegal</a>;
<a name="l00170"></a>00170 *begin = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span>(u);
<a name="l00171"></a>00171 <span class="keywordflow">return</span> 1;
<a name="l00172"></a>00172 }
<a name="l00173"></a>00173 };
<a name="l00174"></a>00174
<a name="l00179"></a>00179 BOOST_LOCALE_DECL std::auto_ptr&lt;base_converter&gt; <a class="code" href="namespaceboost_1_1locale_1_1util.html#aa8e8480ddadc3e972aeb4d468446db64">create_utf8_converter</a>();
<a name="l00187"></a>00187 BOOST_LOCALE_DECL std::auto_ptr&lt;base_converter&gt; <a class="code" href="namespaceboost_1_1locale_1_1util.html#a79624ad8d782ad41d5edf90b6c830631">create_simple_converter</a>(std::string <span class="keyword">const</span> &amp;encoding);
<a name="l00188"></a>00188
<a name="l00189"></a>00189
<a name="l00201"></a>00201 BOOST_LOCALE_DECL
<a name="l00202"></a>00202 std::locale <a class="code" href="namespaceboost_1_1locale_1_1util.html#a3e6728910dc947c3062c6bfd28b70fc4">create_codecvt</a>(std::locale <span class="keyword">const</span> &amp;in,std::auto_ptr&lt;base_converter&gt; cvt,<a class="code" href="namespaceboost_1_1locale.html#a8c993aaf15e683e97d062560ccf914d8" title="type that specifies the character type that locales can be generated for">character_facet_type</a> type);
<a name="l00203"></a>00203
<a name="l00204"></a>00204 } <span class="comment">// util</span>
<a name="l00205"></a>00205 } <span class="comment">// locale </span>
<a name="l00206"></a>00206 } <span class="comment">// boost</span>
<a name="l00207"></a>00207
<a name="l00208"></a>00208 <span class="preprocessor">#endif</span>
<a name="l00209"></a>00209 <span class="preprocessor"></span><span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
&copy; Copyright 2009-2011 Artyom Beilis, Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>, Version 1.0.
</small></address>
</body>
</html>