1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template period_formatter</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.period_formatter_hpp" title="Header <boost/date_time/period_formatter.hpp>">
<link rel="prev" href="period.html" title="Class template period">
<link rel="next" href="period_parser.html" title="Class template period_parser">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="period.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.period_formatter_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="period_parser.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="refentry" title="Class template period_formatter">
<a name="boost.date_time.period_formatter"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template period_formatter</span></h2>
<p>boost::date_time::period_formatter — Not a facet, but a class used to specify and control period formats. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="emphasis"><em>// In header: <<a class="link" href="../../date_time/doxy.html#header.boost.date_time.period_formatter_hpp" title="Header <boost/date_time/period_formatter.hpp>">boost/date_time/period_formatter.hpp</a>>
</em></span><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT,
<span class="bold"><strong>typename</strong></span> OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
<span class="bold"><strong>class</strong></span> <a class="link" href="period_formatter.html" title="Class template period_formatter">period_formatter</a> {
<span class="bold"><strong>public</strong></span>:
<span class="emphasis"><em>// types</em></span>
<span class="bold"><strong>typedef</strong></span> std::basic_string< CharT > <a name="boost.date_time.period_formatter.string_type"></a>string_type;
<span class="bold"><strong>typedef</strong></span> CharT <a name="boost.date_time.period_formatter.char_type"></a>char_type;
<span class="bold"><strong>typedef</strong></span> std::basic_string< char_type >::const_iterator <a name="boost.date_time.period_formatter.const_itr_type"></a>const_itr_type;
<span class="bold"><strong>typedef</strong></span> std::vector< std::basic_string< CharT > > <a name="boost.date_time.period_formatter.collection_type"></a>collection_type;
<span class="bold"><strong>enum</strong></span> <a name="boost.date_time.period_formatter.range_display_options"></a>range_display_options { AS_OPEN_RANGE, AS_CLOSED_RANGE };
<span class="emphasis"><em>// <a class="link" href="period_formatter.html#boost.date_time.period_formatterconstruct-copy-destruct">construct/copy/destruct</a></em></span>
<a class="link" href="period_formatter.html#id577783-bb">period_formatter</a>(range_display_options = AS_CLOSED_RANGE,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_separator,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_start_delimeter,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_open_range_end_delimeter,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_closed_range_end_delimeter);
<span class="emphasis"><em>// <a class="link" href="period_formatter.html#id356460-bb">public member functions</a></em></span>
<span class="type">OutItrT</span> <a class="link" href="period_formatter.html#id356464-bb">put_period_separator</a>(OutItrT &) <span class="bold"><strong>const</strong></span>;
<span class="type">OutItrT</span> <a class="link" href="period_formatter.html#id582659-bb">put_period_start_delimeter</a>(OutItrT &) <span class="bold"><strong>const</strong></span>;
<span class="type">OutItrT</span> <a class="link" href="period_formatter.html#id582676-bb">put_period_end_delimeter</a>(OutItrT &) <span class="bold"><strong>const</strong></span>;
<span class="type">range_display_options</span> <a class="link" href="period_formatter.html#id582693-bb">range_option</a>() <span class="bold"><strong>const</strong></span>;
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="period_formatter.html#id582701-bb">range_option</a>(range_display_options) <span class="bold"><strong>const</strong></span>;
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="period_formatter.html#id339884-bb">delimiter_strings</a>(<span class="bold"><strong>const</strong></span> string_type &, <span class="bold"><strong>const</strong></span> string_type &,
<span class="bold"><strong>const</strong></span> string_type &, <span class="bold"><strong>const</strong></span> string_type &) ;
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> period_type, <span class="bold"><strong>typename</strong></span> facet_type>
<span class="type">OutItrT</span> <a class="link" href="period_formatter.html#id606271-bb">put_period</a>(OutItrT, std::ios_base &, char_type,
<span class="bold"><strong>const</strong></span> period_type &, <span class="bold"><strong>const</strong></span> facet_type &) <span class="bold"><strong>const</strong></span>;
<span class="bold"><strong>static</strong></span> <span class="type"><span class="bold"><strong>const</strong></span> char_type</span> default_period_separator;
<span class="bold"><strong>static</strong></span> <span class="type"><span class="bold"><strong>const</strong></span> char_type</span> default_period_start_delimeter;
<span class="bold"><strong>static</strong></span> <span class="type"><span class="bold"><strong>const</strong></span> char_type</span> default_period_open_range_end_delimeter;
<span class="bold"><strong>static</strong></span> <span class="type"><span class="bold"><strong>const</strong></span> char_type</span> default_period_closed_range_end_delimeter;
};</pre></div>
<div class="refsect1" title="Description">
<a name="id812229"></a><h2>Description</h2>
<p>Provides settings for the following:</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>period_separator -- default '/'</p></li>
<li class="listitem"><p>period_open_start_delimeter -- default '['</p></li>
<li class="listitem"><p>period_open_range_end_delimeter -- default ')'</p></li>
<li class="listitem"><p>period_closed_range_end_delimeter -- default ']'</p></li>
<li class="listitem"><p>display_as_open_range, display_as_closed_range -- default closed_range</p></li>
</ul></div>
<p>
</p>
<p>Thus the default formatting for a period is as follows: </p>
<pre class="programlisting"> [period.start()/period.last()]
*
</pre>
<p> So for a typical date_period this would be </p>
<pre class="programlisting"> [2004-Jan-04/2004-Feb-01]
*
</pre>
<p> where the date formatting is controlled by the date facet </p>
<div class="refsect2" title="period_formatter public construct/copy/destruct">
<a name="id812276"></a><h3>
<a name="boost.date_time.period_formatterconstruct-copy-destruct"></a><code class="computeroutput">period_formatter</code>
public
construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="id577783-bb"></a>period_formatter(range_display_options range_option_in = AS_CLOSED_RANGE,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_separator = default_period_separator,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_start_delimeter = default_period_start_delimeter,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_open_range_end_delimeter = default_period_open_range_end_delimeter,
<span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_closed_range_end_delimeter = default_period_closed_range_end_delimeter);</pre>Constructor that sets up period formatter options -- default should suffice most cases. </li></ol></div>
</div>
<div class="refsect2" title="period_formatter public member functions">
<a name="id812365"></a><h3>
<a name="id356460-bb"></a><code class="computeroutput">period_formatter</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type">OutItrT</span> <a name="id356464-bb"></a>put_period_separator(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre>Puts the characters between period elements into stream -- default is /. </li>
<li class="listitem">
<pre class="literallayout"><span class="type">OutItrT</span> <a name="id582659-bb"></a>put_period_start_delimeter(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre>Puts the period start characters into stream -- default is [. </li>
<li class="listitem">
<pre class="literallayout"><span class="type">OutItrT</span> <a name="id582676-bb"></a>put_period_end_delimeter(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre>Puts the period end characters into stream as controled by open/closed range setting. </li>
<li class="listitem"><pre class="literallayout"><span class="type">range_display_options</span> <a name="id582693-bb"></a>range_option() <span class="bold"><strong>const</strong></span>;</pre></li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id582701-bb"></a>range_option(range_display_options option) <span class="bold"><strong>const</strong></span>;</pre>Reset the range_option control. </li>
<li class="listitem"><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id339884-bb"></a>delimiter_strings(<span class="bold"><strong>const</strong></span> string_type & separator,
<span class="bold"><strong>const</strong></span> string_type & start_delim,
<span class="bold"><strong>const</strong></span> string_type & open_end_delim,
<span class="bold"><strong>const</strong></span> string_type & closed_end_delim) ;</pre></li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> period_type, <span class="bold"><strong>typename</strong></span> facet_type>
<span class="type">OutItrT</span> <a name="id606271-bb"></a>put_period(OutItrT next, std::ios_base & a_ios, char_type a_fill,
<span class="bold"><strong>const</strong></span> period_type & p, <span class="bold"><strong>const</strong></span> facet_type & facet) <span class="bold"><strong>const</strong></span>;</pre>Generic code to output a period -- no matter the period type. <p>This generic code will output any period using a facet to to output the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be formatted according the to setup in the passed facet parameter.</p>
<p>The steps for formatting a period are always the same:</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>put the start delimiter</p></li>
<li class="listitem"><p>put start element</p></li>
<li class="listitem"><p>put the separator</p></li>
<li class="listitem"><p>put either last or end element depending on range settings</p></li>
<li class="listitem"><p>put end delimeter depending on range settings</p></li>
</ul></div>
<p>
</p>
<p>Thus for a typical date period the result might look like this: </p>
<pre class="programlisting"> [March 01, 2004/June 07, 2004] <-- closed range
[March 01, 2004/June 08, 2004) <-- open range
*
</pre>
<p> </p>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
<code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="period.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.period_formatter_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="period_parser.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|