| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
|---|
| 4 | <title>Class template period_formatter</title> |
|---|
| 5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
|---|
| 6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
|---|
| 7 | <link rel="start" href="index.html" title="The Boost C++ Libraries"> |
|---|
| 8 | <link rel="up" href="date_time/doxy.html#id2407150" title="Header <boost/date_time/period_formatter.hpp>"> |
|---|
| 9 | <link rel="prev" href="period.html" title="Class template period"> |
|---|
| 10 | <link rel="next" href="period_parser.html" title="Class template period_parser"> |
|---|
| 11 | </head> |
|---|
| 12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
|---|
| 13 | <table cellpadding="2" width="100%"> |
|---|
| 14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td> |
|---|
| 15 | <td align="center"><a href="../../index.htm">Home</a></td> |
|---|
| 16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
|---|
| 17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
|---|
| 18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
|---|
| 19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
|---|
| 20 | </table> |
|---|
| 21 | <hr> |
|---|
| 22 | <div class="spirit-nav"> |
|---|
| 23 | <a accesskey="p" href="period.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2407150"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="period_parser.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 24 | </div> |
|---|
| 25 | <div class="refentry" lang="en"> |
|---|
| 26 | <a name="period_formatter"></a><div class="titlepage"></div> |
|---|
| 27 | <div class="refnamediv"> |
|---|
| 28 | <h2><span class="refentrytitle">Class template period_formatter</span></h2> |
|---|
| 29 | <p>boost::date_time::period_formatter — Not a facet, but a class used to specify and control period formats. </p> |
|---|
| 30 | </div> |
|---|
| 31 | <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> |
|---|
| 32 | <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT, |
|---|
| 33 | <span class="bold"><strong>typename</strong></span> OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > |
|---|
| 34 | <span class="bold"><strong>class</strong></span> period_formatter { |
|---|
| 35 | <span class="bold"><strong>public</strong></span>: |
|---|
| 36 | <span class="emphasis"><em>// types</em></span> |
|---|
| 37 | <span class="bold"><strong>typedef</strong></span> std::basic_string< CharT > string_type; |
|---|
| 38 | <span class="bold"><strong>typedef</strong></span> CharT char_type; |
|---|
| 39 | <span class="bold"><strong>typedef</strong></span> std::basic_string< char_type >::const_iterator const_itr_type; |
|---|
| 40 | <span class="bold"><strong>typedef</strong></span> std::vector< std::basic_string< CharT > > collection_type; |
|---|
| 41 | |
|---|
| 42 | <span class="emphasis"><em>// <a href="period_formatter.html#period_formatterconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
|---|
| 43 | <a href="period_formatter.html#id2373145-bb">period_formatter</a>(range_display_options = AS_CLOSED_RANGE, |
|---|
| 44 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_separator, |
|---|
| 45 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_start_delimeter, |
|---|
| 46 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_open_range_end_delimeter, |
|---|
| 47 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_closed_range_end_delimeter); |
|---|
| 48 | |
|---|
| 49 | <span class="emphasis"><em>// <a href="period_formatter.html#id2481144-bb">public member functions</a></em></span> |
|---|
| 50 | <span class="type">OutItrT</span> <a href="period_formatter.html#id2481148-bb">put_period_separator</a>(OutItrT &) <span class="bold"><strong>const</strong></span>; |
|---|
| 51 | <span class="type">OutItrT</span> <a href="period_formatter.html#id2481176-bb">put_period_start_delimeter</a>(OutItrT &) <span class="bold"><strong>const</strong></span>; |
|---|
| 52 | <span class="type">OutItrT</span> <a href="period_formatter.html#id2506948-bb">put_period_end_delimeter</a>(OutItrT &) <span class="bold"><strong>const</strong></span>; |
|---|
| 53 | <span class="type">range_display_options</span> <a href="period_formatter.html#id2506975-bb">range_option</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 54 | <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period_formatter.html#id2506988-bb">range_option</a>(range_display_options) <span class="bold"><strong>const</strong></span>; |
|---|
| 55 | <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period_formatter.html#id2479018-bb">delimiter_strings</a>(<span class="bold"><strong>const</strong></span> string_type &, <span class="bold"><strong>const</strong></span> string_type &, |
|---|
| 56 | <span class="bold"><strong>const</strong></span> string_type &, <span class="bold"><strong>const</strong></span> string_type &) ; |
|---|
| 57 | <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> |
|---|
| 58 | <span class="type">OutItrT</span> <a href="period_formatter.html#id2395795-bb">put_period</a>(OutItrT, std::ios_base &, char_type, |
|---|
| 59 | <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>; |
|---|
| 60 | |
|---|
| 61 | <span class="bold"><strong>static</strong></span> const char_type default_period_separator; |
|---|
| 62 | <span class="bold"><strong>static</strong></span> const char_type default_period_start_delimeter; |
|---|
| 63 | <span class="bold"><strong>static</strong></span> const char_type default_period_open_range_end_delimeter; |
|---|
| 64 | <span class="bold"><strong>static</strong></span> const char_type default_period_closed_range_end_delimeter; |
|---|
| 65 | };</pre></div> |
|---|
| 66 | <div class="refsect1" lang="en"> |
|---|
| 67 | <a name="id2647460"></a><h2>Description</h2> |
|---|
| 68 | <p>Provides settings for the following:</p> |
|---|
| 69 | <div class="itemizedlist"><ul type="disc"> |
|---|
| 70 | <li><p>period_separator -- default '/'</p></li> |
|---|
| 71 | <li><p>period_open_start_delimeter -- default '['</p></li> |
|---|
| 72 | <li><p>period_open_range_end_delimeter -- default ')'</p></li> |
|---|
| 73 | <li><p>period_closed_range_end_delimeter -- default ']'</p></li> |
|---|
| 74 | <li><p>display_as_open_range, display_as_closed_range -- default closed_range</p></li> |
|---|
| 75 | </ul></div> |
|---|
| 76 | <p>Thus the default formatting for a period is as follows: </p> |
|---|
| 77 | <pre class="programlisting"> [period.start()/period.last()] |
|---|
| 78 | * |
|---|
| 79 | </pre> |
|---|
| 80 | <p>So for a typical date_period this would be </p> |
|---|
| 81 | <pre class="programlisting"> [2004-Jan-04/2004-Feb-01] |
|---|
| 82 | * |
|---|
| 83 | </pre> |
|---|
| 84 | <p>where the date formatting is controlled by the date facet </p> |
|---|
| 85 | <div class="refsect2" lang="en"> |
|---|
| 86 | <a name="id2647504"></a><h3> |
|---|
| 87 | <a name="period_formatterconstruct-copy-destruct"></a><code class="computeroutput">period_formatter</code> construct/copy/destruct</h3> |
|---|
| 88 | <div class="orderedlist"><ol type="1"><li><pre class="literallayout"><a name="id2373145-bb"></a>period_formatter(range_display_options range_option = AS_CLOSED_RANGE, |
|---|
| 89 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_separator = default_period_separator, |
|---|
| 90 | <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_start_delimeter = default_period_start_delimeter, |
|---|
| 91 | <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, |
|---|
| 92 | <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></li></ol></div> |
|---|
| 93 | </div> |
|---|
| 94 | <div class="refsect2" lang="en"> |
|---|
| 95 | <a name="id2647601"></a><h3> |
|---|
| 96 | <a name="id2481144-bb"></a><code class="computeroutput">period_formatter</code> public member functions</h3> |
|---|
| 97 | <div class="orderedlist"><ol type="1"> |
|---|
| 98 | <li><pre class="literallayout"><span class="type">OutItrT</span> <a name="id2481148-bb"></a>put_period_separator(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 99 | <li><pre class="literallayout"><span class="type">OutItrT</span> <a name="id2481176-bb"></a>put_period_start_delimeter(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 100 | <li><pre class="literallayout"><span class="type">OutItrT</span> <a name="id2506948-bb"></a>put_period_end_delimeter(OutItrT & oitr) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 101 | <li><pre class="literallayout"><span class="type">range_display_options</span> <a name="id2506975-bb"></a>range_option() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 102 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2506988-bb"></a>range_option(range_display_options option) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 103 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2479018-bb"></a>delimiter_strings(<span class="bold"><strong>const</strong></span> string_type & separator, |
|---|
| 104 | <span class="bold"><strong>const</strong></span> string_type & start_delim, |
|---|
| 105 | <span class="bold"><strong>const</strong></span> string_type & open_end_delim, |
|---|
| 106 | <span class="bold"><strong>const</strong></span> string_type & closed_end_delim) ;</pre></li> |
|---|
| 107 | <li> |
|---|
| 108 | <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> |
|---|
| 109 | <span class="type">OutItrT</span> <a name="id2395795-bb"></a>put_period(OutItrT next, std::ios_base & a_ios, char_type a_fill, |
|---|
| 110 | <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> |
|---|
| 111 | <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> |
|---|
| 112 | <p>The steps for formatting a period are always the same:</p> |
|---|
| 113 | <div class="itemizedlist"><ul type="disc"> |
|---|
| 114 | <li><p>put the start delimiter</p></li> |
|---|
| 115 | <li><p>put start element</p></li> |
|---|
| 116 | <li><p>put the separator</p></li> |
|---|
| 117 | <li><p>put either last or end element depending on range settings</p></li> |
|---|
| 118 | <li><p>put end delimeter depending on range settings</p></li> |
|---|
| 119 | </ul></div> |
|---|
| 120 | <p>Thus for a typical date period the result might look like this: </p> |
|---|
| 121 | <pre class="programlisting"> [March 01, 2004/June 07, 2004] <-- closed range |
|---|
| 122 | [March 01, 2004/June 08, 2004) <-- open range |
|---|
| 123 | |
|---|
| 124 | * |
|---|
| 125 | </pre> |
|---|
| 126 | </li> |
|---|
| 127 | </ol></div> |
|---|
| 128 | </div> |
|---|
| 129 | </div> |
|---|
| 130 | </div> |
|---|
| 131 | <table width="100%"><tr> |
|---|
| 132 | <td align="left"></td> |
|---|
| 133 | <td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td> |
|---|
| 134 | </tr></table> |
|---|
| 135 | <hr> |
|---|
| 136 | <div class="spirit-nav"> |
|---|
| 137 | <a accesskey="p" href="period.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2407150"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="period_parser.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 138 | </div> |
|---|
| 139 | </body> |
|---|
| 140 | </html> |
|---|