<!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.6"/>
<title>Boost.Locale: boost::locale::basic_format&lt; CharType &gt; Class Template 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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</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="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>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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>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><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classboost_1_1locale_1_1basic__format.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classboost_1_1locale_1_1basic__format-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">boost::locale::basic_format&lt; CharType &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__format.html">Format</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>a printf like class that allows type-safe and locale aware message formatting  
 <a href="classboost_1_1locale_1_1basic__format.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="format_8hpp_source.html">boost/locale/format.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a45c16f2e69842b8d223d240bbd6e210a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a45c16f2e69842b8d223d240bbd6e210a"></a>
typedef CharType&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a45c16f2e69842b8d223d240bbd6e210a">char_type</a></td></tr>
<tr class="memdesc:a45c16f2e69842b8d223d240bbd6e210a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Underlying character type. <br/></td></tr>
<tr class="separator:a45c16f2e69842b8d223d240bbd6e210a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a75213e5cc9d113f6b25e72542a4841f5"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="classboost_1_1locale_1_1basic__message.html">basic_message</a>&lt; <a class="el" href="classboost_1_1locale_1_1basic__format.html#a45c16f2e69842b8d223d240bbd6e210a">char_type</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a75213e5cc9d113f6b25e72542a4841f5">message_type</a></td></tr>
<tr class="separator:a75213e5cc9d113f6b25e72542a4841f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0e1263d23f67aa38b4d857031fccf973"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0e1263d23f67aa38b4d857031fccf973"></a>
typedef std::basic_string<br class="typebreak"/>
&lt; CharType &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a0e1263d23f67aa38b4d857031fccf973">string_type</a></td></tr>
<tr class="memdesc:a0e1263d23f67aa38b4d857031fccf973"><td class="mdescLeft">&#160;</td><td class="mdescRight">string type for this type of character <br/></td></tr>
<tr class="separator:a0e1263d23f67aa38b4d857031fccf973"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6aba7e54f0065f2697d13ff8a859309a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6aba7e54f0065f2697d13ff8a859309a"></a>
typedef std::basic_ostream<br class="typebreak"/>
&lt; CharType &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a6aba7e54f0065f2697d13ff8a859309a">stream_type</a></td></tr>
<tr class="memdesc:a6aba7e54f0065f2697d13ff8a859309a"><td class="mdescLeft">&#160;</td><td class="mdescRight">output stream type for this type of character <br/></td></tr>
<tr class="separator:a6aba7e54f0065f2697d13ff8a859309a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><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:a4c885ae60a5b867863b79acb75feff9e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a4c885ae60a5b867863b79acb75feff9e">basic_format</a> (<a class="el" href="classboost_1_1locale_1_1basic__format.html#a0e1263d23f67aa38b4d857031fccf973">string_type</a> format_string)</td></tr>
<tr class="separator:a4c885ae60a5b867863b79acb75feff9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a155e8e60061da7461bbcc958d600c190"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a155e8e60061da7461bbcc958d600c190">basic_format</a> (<a class="el" href="classboost_1_1locale_1_1basic__format.html#a75213e5cc9d113f6b25e72542a4841f5">message_type</a> const &amp;trans)</td></tr>
<tr class="separator:a155e8e60061da7461bbcc958d600c190"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a24de7f69a5d95fd6181d888f07fc6770"><td class="memTemplParams" colspan="2">template&lt;typename Formattible &gt; </td></tr>
<tr class="memitem:a24de7f69a5d95fd6181d888f07fc6770"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classboost_1_1locale_1_1basic__format.html">basic_format</a> &amp;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a24de7f69a5d95fd6181d888f07fc6770">operator%</a> (Formattible const &amp;object)</td></tr>
<tr class="separator:a24de7f69a5d95fd6181d888f07fc6770"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6bc65d7993e3ab6ad51809ef8fb65400"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a0e1263d23f67aa38b4d857031fccf973">string_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a6bc65d7993e3ab6ad51809ef8fb65400">str</a> (std::locale const &amp;loc=std::locale()) const </td></tr>
<tr class="separator:a6bc65d7993e3ab6ad51809ef8fb65400"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a457c9228d13e80da3c807a51aa5ef6cd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a457c9228d13e80da3c807a51aa5ef6cd">write</a> (<a class="el" href="classboost_1_1locale_1_1basic__format.html#a6aba7e54f0065f2697d13ff8a859309a">stream_type</a> &amp;out) const </td></tr>
<tr class="separator:a457c9228d13e80da3c807a51aa5ef6cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename CharType&gt;<br/>
class boost::locale::basic_format&lt; CharType &gt;</h3>

<p>a printf like class that allows type-safe and locale aware message formatting </p>
<p>This class creates a formatted message similar to printf or boost::format and receives formatted entries via operator %.</p>
<p>For example </p>
<div class="fragment"><div class="line">cout &lt;&lt; <a class="code" href="group__format.html#gad7914df7b54382c1ad7f5360676fe2e8">format</a>(<span class="stringliteral">&quot;Hello {1}, you are {2} years old&quot;</span>) % name % age &lt;&lt; endl;</div>
</div><!-- fragment --><p>Formatting is enclosed between curly brackets <code>{</code> <code>}</code> and defined by a comma separated list of flags in the format key[=value] value may also be text included between single quotes <code>'</code> that is used for special purposes where inclusion of non-ASCII text is allowed</p>
<p>Including of literal <code>{</code> and <code>}</code> is possible by specifying double brackets <code>{{</code> and <code>}}</code> accordingly.</p>
<p>For example:</p>
<div class="fragment"><div class="line">cout &lt;&lt; <a class="code" href="group__format.html#gad7914df7b54382c1ad7f5360676fe2e8">format</a>(<span class="stringliteral">&quot;The height of water at {1,time} is {2,num=fixed,precision=3}&quot;</span>) % <a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">time</a> % height;</div>
</div><!-- fragment --><p>The special key &ndash; a number without a value defines the position of an input parameter. List of keys:</p>
<ul>
<li><code></code>[0-9]+ &ndash; digits, the index of a formatted parameter &ndash; mandatory key.</li>
<li><code>num</code> or <code>number</code> &ndash; format a number. Optional values are:<ul>
<li><code>hex</code> &ndash; display hexadecimal number</li>
<li><code>oct</code> &ndash; display in octal format</li>
<li><code>sci</code> or <code>scientific</code> &ndash; display in scientific format</li>
<li><code>fix</code> or <code>fixed</code> &ndash; display in fixed format</li>
</ul>
For example <code>number=sci</code> </li>
<li><code>cur</code> or <code>currency</code> &ndash; format currency. Optional values are:<ul>
<li><code>iso</code> &ndash; display using ISO currency symbol.</li>
<li><code>nat</code> or <code>national</code> &ndash; display using national currency symbol.</li>
</ul>
</li>
<li><code>per</code> or <code>percent</code> &ndash; format percent value.</li>
<li><code>date</code>, <code>time</code> , <code>datetime</code> or <code>dt</code> &ndash; format date, time or date and time. Optional values are:<ul>
<li><code>s</code> or <code>short</code> &ndash; display in short format</li>
<li><code>m</code> or <code>medium</code> &ndash; display in medium format.</li>
<li><code>l</code> or <code>long</code> &ndash; display in long format.</li>
<li><code>f</code> or <code>full</code> &ndash; display in full format.</li>
</ul>
</li>
<li><code>ftime</code> with string (quoted) parameter &ndash; display as with <code>strftime</code> see, <code><a class="el" href="group__manipulators.html#ga84cc8985e5305ef54394e84c10223866">as::ftime</a></code> manipulator</li>
<li><code>spell</code> or <code>spellout</code> &ndash; spell the number.</li>
<li><code>ord</code> or <code>ordinal</code> &ndash; format ordinal number (1st, 2nd... etc)</li>
<li><code>left</code> or <code>&lt;</code> &ndash; align to left.</li>
<li><code>right</code> or <code>&gt;</code> &ndash; align to right.</li>
<li><code>width</code> or <code>w</code> &ndash; set field width (requires parameter).</li>
<li><code>precision</code> or <code>p</code> &ndash; set precision (requires parameter).</li>
<li><code>locale</code> &ndash; with parameter &ndash; switch locale for current operation. This command generates locale with formatting facets giving more fine grained control of formatting. For example: <div class="fragment"><div class="line">cout &lt;&lt; <a class="code" href="group__format.html#gad7914df7b54382c1ad7f5360676fe2e8">format</a>(<span class="stringliteral">&quot;Today {1,date} ({1,date,locale=he_IL.UTF-8@calendar=hebrew,date} Hebrew Date)&quot;</span>) % <a class="code" href="group__manipulators.html#gae05b82e6658dc573521518fed5f5c77f">date</a>;</div>
</div><!-- fragment --></li>
<li><code>timezone</code> or <code>tz</code> &ndash; the name of the timezone to display the time in. For example:<br/>
<div class="fragment"><div class="line">cout &lt;&lt; <a class="code" href="group__format.html#gad7914df7b54382c1ad7f5360676fe2e8">format</a>(<span class="stringliteral">&quot;Time is: Local {1,time}, ({1,time,tz=EET} Eastern European Time)&quot;</span>) % <a class="code" href="group__manipulators.html#gae05b82e6658dc573521518fed5f5c77f">date</a>;</div>
</div><!-- fragment --></li>
<li><code>local</code> - display the time in local time</li>
<li><code>gmt</code> - display the time in UTC time scale <div class="fragment"><div class="line">cout &lt;&lt; <a class="code" href="group__format.html#gad7914df7b54382c1ad7f5360676fe2e8">format</a>(<span class="stringliteral">&quot;Local time is: {1,time,local}, universal time is {1,time,gmt}&quot;</span>) % <a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">time</a>;</div>
</div><!-- fragment --></li>
</ul>
<p>Invalid formatting strings are slightly ignored. This would prevent from translator to crash the program in unexpected location. </p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a class="anchor" id="a75213e5cc9d113f6b25e72542a4841f5"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">typedef <a class="el" href="classboost_1_1locale_1_1basic__message.html">basic_message</a>&lt;<a class="el" href="classboost_1_1locale_1_1basic__format.html#a45c16f2e69842b8d223d240bbd6e210a">char_type</a>&gt; <a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::<a class="el" href="classboost_1_1locale_1_1basic__format.html#a75213e5cc9d113f6b25e72542a4841f5">message_type</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The translation message type </p>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a4c885ae60a5b867863b79acb75feff9e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::<a class="el" href="classboost_1_1locale_1_1basic__format.html">basic_format</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a0e1263d23f67aa38b4d857031fccf973">string_type</a>&#160;</td>
          <td class="paramname"><em>format_string</em></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>Create a format class for <em>format_string</em> </p>

</div>
</div>
<a class="anchor" id="a155e8e60061da7461bbcc958d600c190"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::<a class="el" href="classboost_1_1locale_1_1basic__format.html">basic_format</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a75213e5cc9d113f6b25e72542a4841f5">message_type</a> const &amp;&#160;</td>
          <td class="paramname"><em>trans</em></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>Create a format class using message <em>trans</em>. The message if translated first according to the rules of target locale and then interpreted as format string </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a24de7f69a5d95fd6181d888f07fc6770"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
<div class="memtemplate">
template&lt;typename Formattible &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classboost_1_1locale_1_1basic__format.html">basic_format</a>&amp; <a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::operator% </td>
          <td>(</td>
          <td class="paramtype">Formattible const &amp;&#160;</td>
          <td class="paramname"><em>object</em></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>Add new parameter to format list. The object should be a type with defined expression out &lt;&lt; object where <code>out</code> is <code>std::basic_ostream</code>. </p>

</div>
</div>
<a class="anchor" id="a6bc65d7993e3ab6ad51809ef8fb65400"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a0e1263d23f67aa38b4d857031fccf973">string_type</a> <a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::str </td>
          <td>(</td>
          <td class="paramtype">std::locale const &amp;&#160;</td>
          <td class="paramname"><em>loc</em> = <code>std::locale()</code></td><td>)</td>
          <td> const</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>Format a string using a locale <em>loc</em> </p>

</div>
</div>
<a class="anchor" id="a457c9228d13e80da3c807a51aa5ef6cd"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename CharType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classboost_1_1locale_1_1basic__format.html">boost::locale::basic_format</a>&lt; CharType &gt;::write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classboost_1_1locale_1_1basic__format.html#a6aba7e54f0065f2697d13ff8a859309a">stream_type</a> &amp;&#160;</td>
          <td class="paramname"><em>out</em></td><td>)</td>
          <td> const</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>write a formatted string to output stream <em>out</em> using out's locale </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>boost/locale/<a class="el" href="format_8hpp_source.html">format.hpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->

    <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>
