UNPKG

boost-react-native-bundle

Version:

Boost library as in https://sourceforge.net/projects/boost/files/boost/1.57.0/

464 lines (450 loc) 76.6 kB
<!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/message.hpp Source File</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><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 id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File&#160;List</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('message_8hpp.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <div class="title">boost/locale/message.hpp</div> </div> </div><!--header--> <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_MESSAGE_HPP_INCLUDED</span> <a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_LOCALE_MESSAGE_HPP_INCLUDED</span> <a name="l00010"></a>00010 <span class="preprocessor"></span> <a name="l00011"></a>00011 <span class="preprocessor">#include &lt;boost/locale/config.hpp&gt;</span> <a name="l00012"></a>00012 <span class="preprocessor">#ifdef BOOST_MSVC</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor"># pragma warning(push)</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor"># pragma warning(disable : 4275 4251 4231 4660)</span> <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#include &lt;locale&gt;</span> <a name="l00017"></a>00017 <span class="preprocessor">#include &lt;string&gt;</span> <a name="l00018"></a>00018 <span class="preprocessor">#include &lt;vector&gt;</span> <a name="l00019"></a>00019 <span class="preprocessor">#include &lt;set&gt;</span> <a name="l00020"></a>00020 <span class="preprocessor">#include &lt;memory&gt;</span> <a name="l00021"></a>00021 <span class="preprocessor">#include &lt;boost/locale/formatting.hpp&gt;</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="keyword">namespace </span>boost { <a name="l00025"></a>00025 <span class="keyword">namespace </span>locale { <a name="l00033"></a>00033 <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00037"></a>00037 <span class="keyword">struct </span>base_message_format: <span class="keyword">public</span> std::locale::facet <a name="l00038"></a>00038 { <a name="l00039"></a>00039 }; <a name="l00040"></a>00040 <a name="l00042"></a>00042 <a name="l00046"></a>00046 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00047"></a><a class="code" href="classboost_1_1locale_1_1message__format.html">00047</a> <span class="keyword">class </span><a class="code" href="classboost_1_1locale_1_1message__format.html" title="This facet provides message formatting abilities.">message_format</a> : <span class="keyword">public</span> base_message_format&lt;CharType&gt; <a name="l00048"></a>00048 { <a name="l00049"></a>00049 <span class="keyword">public</span>: <a name="l00050"></a>00050 <a name="l00054"></a><a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">00054</a> <span class="keyword">typedef</span> CharType <a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a>; <a name="l00058"></a><a class="code" href="group__message.html#gaaa932705310ce196fccc9d672b25518f">00058</a> <span class="keyword">typedef</span> std::basic_string&lt;CharType&gt; <a class="code" href="group__message.html#gaaa932705310ce196fccc9d672b25518f">string_type</a>; <a name="l00059"></a>00059 <a name="l00063"></a><a class="code" href="group__message.html#gafa681d0df94a35f9d75c16dea099d03e">00063</a> <a class="code" href="group__message.html#gafa681d0df94a35f9d75c16dea099d03e">message_format</a>(<span class="keywordtype">size_t</span> refs = 0) : <a name="l00064"></a>00064 base_message_format&lt;CharType&gt;(refs) <a name="l00065"></a>00065 { <a name="l00066"></a>00066 } <a name="l00067"></a>00067 <a name="l00078"></a>00078 <span class="keyword">virtual</span> <a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *<span class="keyword">get</span>(<span class="keywordtype">int</span> domain_id,<a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *context,<a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *id) <span class="keyword">const</span> = 0; <a name="l00092"></a>00092 <span class="keyword">virtual</span> <a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *<span class="keyword">get</span>(<span class="keywordtype">int</span> domain_id,<a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *context,<a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *single_id,<span class="keywordtype">int</span> n) <span class="keyword">const</span> = 0; <a name="l00093"></a>00093 <a name="l00097"></a>00097 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="group__message.html#ga73e25178ba9ef91ebe1df0aade4d8ae6">domain</a>(std::string <span class="keyword">const</span> &amp;<a class="code" href="group__message.html#ga73e25178ba9ef91ebe1df0aade4d8ae6">domain</a>) <span class="keyword">const</span> = 0; <a name="l00098"></a>00098 <a name="l00107"></a>00107 <span class="keyword">virtual</span> <a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *<a class="code" href="group__message.html#ga3f2c9d7f9a363efa607738083a986251">convert</a>(<a class="code" href="group__message.html#ga83f473295edf14b9e1ae1476b81231bc">char_type</a> <span class="keyword">const</span> *msg,<a class="code" href="group__message.html#gaaa932705310ce196fccc9d672b25518f">string_type</a> &amp;buffer) <span class="keyword">const</span> = 0; <a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="preprocessor">#if defined (__SUNPRO_CC) &amp;&amp; defined (_RWSTD_VER)</span> <a name="l00110"></a>00110 <span class="preprocessor"></span> std::locale::id&amp; __get_id (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> id; } <a name="l00111"></a>00111 <span class="preprocessor">#endif</span> <a name="l00112"></a>00112 <span class="preprocessor"></span> <span class="keyword">protected</span>: <a name="l00113"></a>00113 <span class="keyword">virtual</span> ~<a class="code" href="group__message.html#gafa681d0df94a35f9d75c16dea099d03e">message_format</a>() <a name="l00114"></a>00114 { <a name="l00115"></a>00115 } <a name="l00116"></a>00116 <a name="l00117"></a>00117 }; <a name="l00118"></a>00118 <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="keyword">namespace </span>details { <a name="l00122"></a>00122 <span class="keyword">inline</span> <span class="keywordtype">bool</span> is_us_ascii_char(<span class="keywordtype">char</span> c) <a name="l00123"></a>00123 { <a name="l00124"></a>00124 <span class="comment">// works for null terminated strings regardless char &quot;signness&quot;</span> <a name="l00125"></a>00125 <span class="keywordflow">return</span> 0&lt;c &amp;&amp; c&lt;0x7F; <a name="l00126"></a>00126 } <a name="l00127"></a>00127 <span class="keyword">inline</span> <span class="keywordtype">bool</span> is_us_ascii_string(<span class="keywordtype">char</span> <span class="keyword">const</span> *msg) <a name="l00128"></a>00128 { <a name="l00129"></a>00129 <span class="keywordflow">while</span>(*msg) { <a name="l00130"></a>00130 <span class="keywordflow">if</span>(!is_us_ascii_char(*msg++)) <a name="l00131"></a>00131 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00137"></a>00137 <span class="keyword">struct </span>string_cast_traits { <a name="l00138"></a>00138 <span class="keyword">static</span> CharType <span class="keyword">const</span> *cast(CharType <span class="keyword">const</span> *msg,std::basic_string&lt;CharType&gt; &amp;<span class="comment">/*unused*/</span>) <a name="l00139"></a>00139 { <a name="l00140"></a>00140 <span class="keywordflow">return</span> msg; <a name="l00141"></a>00141 } <a name="l00142"></a>00142 }; <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="keyword">template</span>&lt;&gt; <a name="l00145"></a>00145 <span class="keyword">struct </span>string_cast_traits&lt;char&gt; { <a name="l00146"></a>00146 <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span> *cast(<span class="keywordtype">char</span> <span class="keyword">const</span> *msg,std::string &amp;buffer) <a name="l00147"></a>00147 { <a name="l00148"></a>00148 <span class="keywordflow">if</span>(is_us_ascii_string(msg)) <a name="l00149"></a>00149 <span class="keywordflow">return</span> msg; <a name="l00150"></a>00150 buffer.reserve(strlen(msg)); <a name="l00151"></a>00151 <span class="keywordtype">char</span> c; <a name="l00152"></a>00152 <span class="keywordflow">while</span>((c=*msg++)!=0) { <a name="l00153"></a>00153 <span class="keywordflow">if</span>(is_us_ascii_char(c)) <a name="l00154"></a>00154 buffer+=c; <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <span class="keywordflow">return</span> buffer.c_str(); <a name="l00157"></a>00157 } <a name="l00158"></a>00158 }; <a name="l00159"></a>00159 } <span class="comment">// details</span> <a name="l00160"></a>00160 <a name="l00162"></a>00162 <a name="l00170"></a>00170 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00171"></a><a class="code" href="classboost_1_1locale_1_1basic__message.html">00171</a> <span class="keyword">class </span><a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> { <a name="l00172"></a>00172 <span class="keyword">public</span>: <a name="l00173"></a>00173 <a name="l00174"></a><a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db">00174</a> <span class="keyword">typedef</span> CharType <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a>; <a name="l00175"></a><a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3">00175</a> <span class="keyword">typedef</span> std::basic_string&lt;char_type&gt; <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a>; <a name="l00176"></a><a class="code" href="group__message.html#gaa63527cb368d0bcd4cb0809138c927df">00176</a> <span class="keyword">typedef</span> <a class="code" href="classboost_1_1locale_1_1message__format.html" title="This facet provides message formatting abilities.">message_format&lt;char_type&gt;</a> <a class="code" href="group__message.html#gaa63527cb368d0bcd4cb0809138c927df" title="The type of the facet the messages are fetched with.">facet_type</a>; <a name="l00177"></a>00177 <a name="l00181"></a><a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">00181</a> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>() : <a name="l00182"></a>00182 n_(0), <a name="l00183"></a>00183 c_id_(0), <a name="l00184"></a>00184 c_context_(0), <a name="l00185"></a>00185 c_plural_(0) <a name="l00186"></a>00186 { <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <a name="l00193"></a><a class="code" href="group__message.html#gae32d7f89d5f268e8d6bae662d8008bae">00193</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *<span class="keywordtype">id</span>) : <a name="l00194"></a>00194 n_(0), <a name="l00195"></a>00195 c_id_(id), <a name="l00196"></a>00196 c_context_(0), <a name="l00197"></a>00197 c_plural_(0) <a name="l00198"></a>00198 { <a name="l00199"></a>00199 } <a name="l00200"></a>00200 <a name="l00207"></a><a class="code" href="group__message.html#ga40bf56415a235f13ee666d51f645f280">00207</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *single,<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *plural,<span class="keywordtype">int</span> n) : <a name="l00208"></a>00208 n_(n), <a name="l00209"></a>00209 c_id_(single), <a name="l00210"></a>00210 c_context_(0), <a name="l00211"></a>00211 c_plural_(plural) <a name="l00212"></a>00212 { <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00220"></a><a class="code" href="group__message.html#ga4d78f8f45467984d7244e2ddbb9e0f6e">00220</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *context,<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *<span class="keywordtype">id</span>) : <a name="l00221"></a>00221 n_(0), <a name="l00222"></a>00222 c_id_(id), <a name="l00223"></a>00223 c_context_(context), <a name="l00224"></a>00224 c_plural_(0) <a name="l00225"></a>00225 { <a name="l00226"></a>00226 } <a name="l00227"></a>00227 <a name="l00234"></a><a class="code" href="group__message.html#gabf9afe77f0254397389289c386bf8a73">00234</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *context,<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *single,<a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *plural,<span class="keywordtype">int</span> n) : <a name="l00235"></a>00235 n_(n), <a name="l00236"></a>00236 c_id_(single), <a name="l00237"></a>00237 c_context_(context), <a name="l00238"></a>00238 c_plural_(plural) <a name="l00239"></a>00239 { <a name="l00240"></a>00240 } <a name="l00241"></a>00241 <a name="l00242"></a>00242 <a name="l00246"></a><a class="code" href="group__message.html#gabbb4365d621a33442ae34ac7c17a9d74">00246</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;<span class="keywordtype">id</span>) : <a name="l00247"></a>00247 n_(0), <a name="l00248"></a>00248 c_id_(0), <a name="l00249"></a>00249 c_context_(0), <a name="l00250"></a>00250 c_plural_(0), <a name="l00251"></a>00251 id_(id) <a name="l00252"></a>00252 { <a name="l00253"></a>00253 } <a name="l00254"></a>00254 <a name="l00260"></a><a class="code" href="group__message.html#ga380f3a258b3b28929bbf01f4e622e71a">00260</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;single,<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;plural,<span class="keywordtype">int</span> <a class="code" href="group__manipulators.html#gaee05db73f5525d9a010cdc3aa02f634f">number</a>) : <a name="l00261"></a>00261 n_(number), <a name="l00262"></a>00262 c_id_(0), <a name="l00263"></a>00263 c_context_(0), <a name="l00264"></a>00264 c_plural_(0), <a name="l00265"></a>00265 id_(single), <a name="l00266"></a>00266 plural_(plural) <a name="l00267"></a>00267 { <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <a name="l00273"></a><a class="code" href="group__message.html#ga8c2fab962e10a46ea85f0188d08e499d">00273</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;context,<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;<span class="keywordtype">id</span>) : <a name="l00274"></a>00274 n_(0), <a name="l00275"></a>00275 c_id_(0), <a name="l00276"></a>00276 c_context_(0), <a name="l00277"></a>00277 c_plural_(0), <a name="l00278"></a>00278 id_(id), <a name="l00279"></a>00279 context_(context) <a name="l00280"></a>00280 { <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <a name="l00288"></a><a class="code" href="group__message.html#gaf8ba10b7b1d45e6c78b84d77e8175d5d">00288</a> <span class="keyword">explicit</span> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;context,<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;single,<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <span class="keyword">const</span> &amp;plural,<span class="keywordtype">int</span> <a class="code" href="group__manipulators.html#gaee05db73f5525d9a010cdc3aa02f634f">number</a>) : <a name="l00289"></a>00289 n_(number), <a name="l00290"></a>00290 c_id_(0), <a name="l00291"></a>00291 c_context_(0), <a name="l00292"></a>00292 c_plural_(0), <a name="l00293"></a>00293 id_(single), <a name="l00294"></a>00294 context_(context), <a name="l00295"></a>00295 plural_(plural) <a name="l00296"></a>00296 { <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00302"></a><a class="code" href="group__message.html#gae6ed9dded4ab78ff28e994b48c766c84">00302</a> <a class="code" href="group__message.html#ga33bdf7fbb164a96a8685b5747afc2b45">basic_message</a>(<a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> <span class="keyword">const</span> &amp;other) : <a name="l00303"></a>00303 n_(other.n_), <a name="l00304"></a>00304 c_id_(other.c_id_), <a name="l00305"></a>00305 c_context_(other.c_context_), <a name="l00306"></a>00306 c_plural_(other.c_plural_), <a name="l00307"></a>00307 id_(other.id_), <a name="l00308"></a>00308 context_(other.context_), <a name="l00309"></a>00309 plural_(other.plural_) <a name="l00310"></a>00310 { <a name="l00311"></a>00311 } <a name="l00312"></a>00312 <a name="l00316"></a><a class="code" href="group__message.html#gae0e786e45ef32cf73efd8495cae45aed">00316</a> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> <span class="keyword">const</span> &amp;<a class="code" href="group__message.html#gae0e786e45ef32cf73efd8495cae45aed">operator=</a>(<a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> <span class="keyword">const</span> &amp;other) <a name="l00317"></a>00317 { <a name="l00318"></a>00318 <span class="keywordflow">if</span>(<span class="keyword">this</span>==&amp;other) { <a name="l00319"></a>00319 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00320"></a>00320 } <a name="l00321"></a>00321 <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> tmp(other); <a name="l00322"></a>00322 <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">swap</a>(tmp); <a name="l00323"></a>00323 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00324"></a>00324 } <a name="l00325"></a>00325 <a name="l00329"></a><a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">00329</a> <span class="keywordtype">void</span> <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">swap</a>(<a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message</a> &amp;other) <a name="l00330"></a>00330 { <a name="l00331"></a>00331 <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">std::swap</a>(n_,other.n_); <a name="l00332"></a>00332 <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">std::swap</a>(c_id_,other.c_id_); <a name="l00333"></a>00333 <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">std::swap</a>(c_context_,other.c_context_); <a name="l00334"></a>00334 <a class="code" href="group__message.html#gac204b563c7c9bd86e5555f129350f0e3">std::swap</a>(c_plural_,other.c_plural_); <a name="l00335"></a>00335 <a name="l00336"></a>00336 id_.swap(other.id_); <a name="l00337"></a>00337 context_.swap(other.context_); <a name="l00338"></a>00338 plural_.swap(other.plural_); <a name="l00339"></a>00339 } <a name="l00340"></a>00340 <a name="l00344"></a>00344 <a name="l00345"></a><a class="code" href="group__message.html#ga8da81038939b85ca248cba50f1deacf1">00345</a> <a class="code" href="group__message.html#ga8da81038939b85ca248cba50f1deacf1">operator string_type </a>()<span class="keyword"> const</span> <a name="l00346"></a>00346 <span class="keyword"> </span>{ <a name="l00347"></a>00347 <span class="keywordflow">return</span> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <a name="l00353"></a><a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">00353</a> <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>()<span class="keyword"> const</span> <a name="l00354"></a>00354 <span class="keyword"> </span>{ <a name="l00355"></a>00355 std::locale loc; <a name="l00356"></a>00356 <span class="keywordflow">return</span> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(loc,0); <a name="l00357"></a>00357 } <a name="l00358"></a>00358 <a name="l00362"></a><a class="code" href="group__message.html#ga26c6489f8269096f835abfb268498fdd">00362</a> <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(std::locale <span class="keyword">const</span> &amp;locale)<span class="keyword"> const</span> <a name="l00363"></a>00363 <span class="keyword"> </span>{ <a name="l00364"></a>00364 <span class="keywordflow">return</span> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(locale,0); <a name="l00365"></a>00365 } <a name="l00366"></a>00366 <a name="l00370"></a><a class="code" href="group__message.html#gaa907a1d3f43fe59cea938e1606f004ee">00370</a> <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(std::locale <span class="keyword">const</span> &amp;locale,std::string <span class="keyword">const</span> &amp;domain_id)<span class="keyword"> const</span> <a name="l00371"></a>00371 <span class="keyword"> </span>{ <a name="l00372"></a>00372 <span class="keywordtype">int</span> <span class="keywordtype">id</span>=0; <a name="l00373"></a>00373 <span class="keywordflow">if</span>(std::has_facet&lt;facet_type&gt;(locale)) <a name="l00374"></a>00374 <span class="keywordtype">id</span>=std::use_facet&lt;facet_type&gt;(locale).<a class="code" href="group__manipulators.html#gab522188e3d82f1d2898b290b9132925e">domain</a>(domain_id); <a name="l00375"></a>00375 <span class="keywordflow">return</span> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(locale,<span class="keywordtype">id</span>); <a name="l00376"></a>00376 } <a name="l00377"></a>00377 <a name="l00381"></a><a class="code" href="group__message.html#ga2d2ca0fe119e4ce4766fd3d42b549314">00381</a> <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(std::string <span class="keyword">const</span> &amp;domain_id)<span class="keyword"> const</span> <a name="l00382"></a>00382 <span class="keyword"> </span>{ <a name="l00383"></a>00383 <span class="keywordtype">int</span> <span class="keywordtype">id</span>=0; <a name="l00384"></a>00384 std::locale loc; <a name="l00385"></a>00385 <span class="keywordflow">if</span>(std::has_facet&lt;facet_type&gt;(loc)) <a name="l00386"></a>00386 <span class="keywordtype">id</span>=std::use_facet&lt;facet_type&gt;(loc).<a class="code" href="group__manipulators.html#gab522188e3d82f1d2898b290b9132925e">domain</a>(domain_id); <a name="l00387"></a>00387 <span class="keywordflow">return</span> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(loc,<span class="keywordtype">id</span>); <a name="l00388"></a>00388 } <a name="l00389"></a>00389 <a name="l00390"></a>00390 <a name="l00394"></a><a class="code" href="group__message.html#gaa51c0f65363d8d1cee83bb07fe45ced5">00394</a> <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> <a class="code" href="group__message.html#ga11c5f400e03e0b16b9a60bd3fae3f168">str</a>(std::locale <span class="keyword">const</span> &amp;loc,<span class="keywordtype">int</span> <span class="keywordtype">id</span>)<span class="keyword"> const</span> <a name="l00395"></a>00395 <span class="keyword"> </span>{ <a name="l00396"></a>00396 <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> buffer; <a name="l00397"></a>00397 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *ptr = <a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">write</a>(loc,<span class="keywordtype">id</span>,buffer); <a name="l00398"></a>00398 <span class="keywordflow">if</span>(ptr == buffer.c_str()) <a name="l00399"></a>00399 <span class="keywordflow">return</span> buffer; <a name="l00400"></a>00400 <span class="keywordflow">else</span> <a name="l00401"></a>00401 buffer = ptr; <a name="l00402"></a>00402 <span class="keywordflow">return</span> buffer; <a name="l00403"></a>00403 } <a name="l00404"></a>00404 <a name="l00405"></a>00405 <a name="l00410"></a><a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">00410</a> <span class="keywordtype">void</span> <a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">write</a>(std::basic_ostream&lt;char_type&gt; &amp;out)<span class="keyword"> const</span> <a name="l00411"></a>00411 <span class="keyword"> </span>{ <a name="l00412"></a>00412 std::locale <span class="keyword">const</span> &amp;loc = out.getloc(); <a name="l00413"></a>00413 <span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code" href="classboost_1_1locale_1_1ios__info.html#a02f6979dffc2df97c3612d72b7c7241b">ios_info::get</a>(out).<a class="code" href="classboost_1_1locale_1_1ios__info.html#a08b1bb49e5806900bfa1901e869497a6">domain_id</a>(); <a name="l00414"></a>00414 <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> buffer; <a name="l00415"></a>00415 out &lt;&lt; <a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">write</a>(loc,<span class="keywordtype">id</span>,buffer); <a name="l00416"></a>00416 } <a name="l00417"></a>00417 <a name="l00418"></a>00418 <span class="keyword">private</span>: <a name="l00419"></a>00419 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *plural()<span class="keyword"> const</span> <a name="l00420"></a>00420 <span class="keyword"> </span>{ <a name="l00421"></a>00421 <span class="keywordflow">if</span>(c_plural_) <a name="l00422"></a>00422 <span class="keywordflow">return</span> c_plural_; <a name="l00423"></a>00423 <span class="keywordflow">if</span>(plural_.empty()) <a name="l00424"></a>00424 <span class="keywordflow">return</span> 0; <a name="l00425"></a>00425 <span class="keywordflow">return</span> plural_.c_str(); <a name="l00426"></a>00426 } <a name="l00427"></a>00427 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *context()<span class="keyword"> const</span> <a name="l00428"></a>00428 <span class="keyword"> </span>{ <a name="l00429"></a>00429 <span class="keywordflow">if</span>(c_context_) <a name="l00430"></a>00430 <span class="keywordflow">return</span> c_context_; <a name="l00431"></a>00431 <span class="keywordflow">if</span>(context_.empty()) <a name="l00432"></a>00432 <span class="keywordflow">return</span> 0; <a name="l00433"></a>00433 <span class="keywordflow">return</span> context_.c_str(); <a name="l00434"></a>00434 } <a name="l00435"></a>00435 <a name="l00436"></a>00436 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *id()<span class="keyword"> const</span> <a name="l00437"></a>00437 <span class="keyword"> </span>{ <a name="l00438"></a>00438 <span class="keywordflow">return</span> c_id_ ? c_id_ : id_.c_str(); <a name="l00439"></a>00439 } <a name="l00440"></a>00440 <a name="l00441"></a>00441 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *<a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">write</a>(std::locale <span class="keyword">const</span> &amp;loc,<span class="keywordtype">int</span> domain_id,<a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> &amp;buffer)<span class="keyword"> const</span> <a name="l00442"></a>00442 <span class="keyword"> </span>{ <a name="l00443"></a>00443 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *translated = 0; <a name="l00444"></a>00444 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> empty_string[1] = {0}; <a name="l00445"></a>00445 <a name="l00446"></a>00446 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *<span class="keywordtype">id</span> = this-&gt;id(); <a name="l00447"></a>00447 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *context = this-&gt;context(); <a name="l00448"></a>00448 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *plural = this-&gt;plural(); <a name="l00449"></a>00449 <a name="l00450"></a>00450 <span class="keywordflow">if</span>(*<span class="keywordtype">id</span> == 0) <a name="l00451"></a>00451 <span class="keywordflow">return</span> empty_string; <a name="l00452"></a>00452 <a name="l00453"></a>00453 <a class="code" href="group__message.html#gaa63527cb368d0bcd4cb0809138c927df" title="The type of the facet the messages are fetched with.">facet_type</a> <span class="keyword">const</span> *facet = 0; <a name="l00454"></a>00454 <span class="keywordflow">if</span>(std::has_facet&lt;facet_type&gt;(loc)) <a name="l00455"></a>00455 facet = &amp;std::use_facet&lt;facet_type&gt;(loc); <a name="l00456"></a>00456 <a name="l00457"></a>00457 <span class="keywordflow">if</span>(facet) { <a name="l00458"></a>00458 <span class="keywordflow">if</span>(!plural) { <a name="l00459"></a>00459 translated = facet-&gt;get(domain_id,context,<span class="keywordtype">id</span>); <a name="l00460"></a>00460 } <a name="l00461"></a>00461 <span class="keywordflow">else</span> { <a name="l00462"></a>00462 translated = facet-&gt;get(domain_id,context,<span class="keywordtype">id</span>,n_); <a name="l00463"></a>00463 } <a name="l00464"></a>00464 } <a name="l00465"></a>00465 <a name="l00466"></a>00466 <span class="keywordflow">if</span>(!translated) { <a name="l00467"></a>00467 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *msg = plural ? ( n_ == 1 ? <span class="keywordtype">id</span> : plural) : <span class="keywordtype">id</span>; <a name="l00468"></a>00468 <a name="l00469"></a>00469 <span class="keywordflow">if</span>(facet) { <a name="l00470"></a>00470 translated = facet-&gt;convert(msg,buffer); <a name="l00471"></a>00471 } <a name="l00472"></a>00472 <span class="keywordflow">else</span> { <a name="l00473"></a>00473 translated = details::string_cast_traits&lt;char_type&gt;::cast(msg,buffer); <a name="l00474"></a>00474 } <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <span class="keywordflow">return</span> translated; <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00480"></a>00480 <a name="l00481"></a>00481 <span class="keywordtype">int</span> n_; <a name="l00482"></a>00482 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *c_id_; <a name="l00483"></a>00483 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *c_context_; <a name="l00484"></a>00484 <a class="code" href="group__message.html#gaa5d8dcf9d7aa01abbe73c841299345db" title="The character this message object is used with.">char_type</a> <span class="keyword">const</span> *c_plural_; <a name="l00485"></a>00485 <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> id_; <a name="l00486"></a>00486 <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> context_; <a name="l00487"></a>00487 <a class="code" href="group__message.html#ga529423e08fc9a8ca9ceef5c56181c6d3" title="The string type this object can be used with.">string_type</a> plural_; <a name="l00488"></a>00488 }; <a name="l00489"></a>00489 <a name="l00490"></a>00490 <a name="l00494"></a><a class="code" href="group__message.html#ga556e3e7696302902b2242a7a94516dee">00494</a> <span class="keyword">typedef</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;char&gt;</a> <a class="code" href="group__message.html#ga556e3e7696302902b2242a7a94516dee">message</a>; <a name="l00498"></a><a class="code" href="group__message.html#gafea131aa123d666905076f34b77326a9">00498</a> <span class="keyword">typedef</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;wchar_t&gt;</a> <a class="code" href="group__message.html#gafea131aa123d666905076f34b77326a9">wmessage</a>; <a name="l00499"></a>00499 <span class="preprocessor"> #ifdef BOOST_HAS_CHAR16_T</span> <a name="l00500"></a>00500 <span class="preprocessor"></span> <a name="l00501"></a>00501 <a name="l00502"></a>00502 <a name="l00503"></a><a class="code" href="group__message.html#ga43ddf342eec2ab9145d04727f8161e1c">00503</a> <span class="keyword">typedef</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;char16_t&gt;</a> <a class="code" href="group__message.html#ga43ddf342eec2ab9145d04727f8161e1c">u16message</a>; <a name="l00504"></a>00504 <span class="preprocessor"> #endif</span> <a name="l00505"></a>00505 <span class="preprocessor"></span><span class="preprocessor"> #ifdef BOOST_HAS_CHAR32_T</span> <a name="l00506"></a>00506 <span class="preprocessor"></span> <a name="l00507"></a>00507 <a name="l00508"></a>00508 <a name="l00509"></a><a class="code" href="group__message.html#ga6c0b40121a07c13de9e712845b43468f">00509</a> <span class="keyword">typedef</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;char32_t&gt;</a> <a class="code" href="group__message.html#ga6c0b40121a07c13de9e712845b43468f">u32message</a>; <a name="l00510"></a>00510 <span class="preprocessor"> #endif</span> <a name="l00511"></a>00511 <span class="preprocessor"></span> <a name="l00515"></a>00515 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00516"></a><a class="code" href="group__message.html#ga6989a96196696d891accb078788e2a6b">00516</a> std::basic_ostream&lt;CharType&gt; &amp;operator&lt;&lt;(std::basic_ostream&lt;CharType&gt; &amp;out,<a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;CharType&gt;</a> <span class="keyword">const</span> &amp;msg) <a name="l00517"></a>00517 { <a name="l00518"></a>00518 msg.<a class="code" href="group__message.html#ga4dd81f4d40c4e8871bb1bf02bbc8e968">write</a>(out); <a name="l00519"></a>00519 <span class="keywordflow">return</span> out; <a name="l00520"></a>00520 } <a name="l00521"></a>00521 <a name="l00525"></a>00525 <a name="l00529"></a>00529 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l00530"></a><a class="code" href="group__message.html#ga58e9599005608845d2b022d499dc97f6">00530</a> <span class="keyword">inline</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;CharType&gt;</a> <a class="code" href="group__message.html#ga58e9599005608845d2b022d499dc97f6" title="Translate a message, msg is not copied.">translate</a>(CharType <span class="keyword">const</span> *msg) <a name="l00531"></a>00531 { <a name="l00532"></a>00532 <span class="keywordflow">return</span> <a class="code" href="classboost_1_1locale_1_1basic__message.html" title="This class represents a message that can be converted to a specific locale message.">basic_message&lt;CharType&gt;</a>(msg); <a name="l00533"></a>00533 } <a name="l00537"></a>00537 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharType&gt; <a name="l005