Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/period_parser.html @ 25

Last change on this file since 25 was 12, checked in by landauf, 18 years ago

added boost

File size: 13.0 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class template period_parser</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#id2394584" title="Header &lt;boost/date_time/period_parser.hpp&gt;">
9<link rel="prev" href="period_formatter.html" title="Class template period_formatter">
10<link rel="next" href="special_values_formatter.html" title="Class template special_values_formatter">
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_formatter.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2394584"><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="special_values_formatter.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="period_parser"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class template period_parser</span></h2>
29<p>boost::date_time::period_parser &#8212; Not a facet, but a class used to specify and control period parsing. </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>&lt;<span class="bold"><strong>typename</strong></span> date_type, <span class="bold"><strong>typename</strong></span> CharT&gt; 
33<span class="bold"><strong>class</strong></span> period_parser {
34<span class="bold"><strong>public</strong></span>:
35  <span class="emphasis"><em>// types</em></span>
36  <span class="bold"><strong>typedef</strong></span> std::basic_string&lt; CharT &gt;                string_type;    
37  <span class="bold"><strong>typedef</strong></span> CharT                                     char_type;      
38  <span class="bold"><strong>typedef</strong></span> std::istreambuf_iterator&lt; CharT &gt;         stream_itr_type;
39  <span class="bold"><strong>typedef</strong></span> <a href="string_parse_tree.html" title="Struct template string_parse_tree">string_parse_tree</a>&lt; CharT &gt;                parse_tree_type;
40  <span class="bold"><strong>typedef</strong></span> parse_tree_type::parse_match_result_type  match_results;  
41  <span class="bold"><strong>typedef</strong></span> std::vector&lt; std::basic_string&lt; CharT &gt; &gt; collection_type;
42
43  <span class="emphasis"><em>// <a href="period_parser.html#period_parserconstruct-copy-destruct">construct/copy/destruct</a></em></span>
44  <a href="period_parser.html#id2520377-bb">period_parser</a>(period_range_option = AS_CLOSED_RANGE,
45                <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_separator,
46                <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_start_delimeter,
47                <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_open_range_end_delimeter,
48                <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> = default_period_closed_range_end_delimeter);
49  <a href="period_parser.html#id2394256-bb">period_parser</a>(<span class="bold"><strong>const</strong></span> <a href="period_parser.html" title="Class template period_parser">period_parser</a>&lt; date_type, CharT &gt; &amp;);
50
51  <span class="emphasis"><em>// <a href="period_parser.html#id2471763-bb">public member functions</a></em></span>
52  <span class="type">period_range_option</span> <a href="period_parser.html#id2471768-bb">range_option</a>() <span class="bold"><strong>const</strong></span>;
53  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period_parser.html#id2471780-bb">range_option</a>(period_range_option) ;
54  <span class="type">collection_type</span> <a href="period_parser.html#id2471803-bb">delimiter_strings</a>() <span class="bold"><strong>const</strong></span>;
55  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period_parser.html#id2471816-bb">delimiter_strings</a>(<span class="bold"><strong>const</strong></span> string_type &amp;, <span class="bold"><strong>const</strong></span> string_type &amp;,
56                         <span class="bold"><strong>const</strong></span> string_type &amp;, <span class="bold"><strong>const</strong></span> string_type &amp;) ;
57  <span class="bold"><strong>template</strong></span>&lt;<span class="bold"><strong>typename</strong></span> period_type, <span class="bold"><strong>typename</strong></span> duration_type, <span class="bold"><strong>typename</strong></span> facet_type&gt; 
58    <span class="type">period_type</span> <a href="period_parser.html#id2468850-bb">get_period</a>(stream_itr_type &amp;, stream_itr_type &amp;,
59                           std::ios_base &amp;, <span class="bold"><strong>const</strong></span> period_type &amp;,
60                           <span class="bold"><strong>const</strong></span> duration_type &amp;, <span class="bold"><strong>const</strong></span> facet_type &amp;) <span class="bold"><strong>const</strong></span>;
61
62  <span class="emphasis"><em>// <a href="period_parser.html#id2394322-bb">private member functions</a></em></span>
63  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period_parser.html#id2529067-bb">consume_delim</a>(stream_itr_type &amp;, stream_itr_type &amp;,
64                     <span class="bold"><strong>const</strong></span> string_type &amp;) <span class="bold"><strong>const</strong></span>;
65
66  <span class="bold"><strong>static</strong></span> const char_type default_period_separator;
67  <span class="bold"><strong>static</strong></span> const char_type default_period_start_delimeter;
68  <span class="bold"><strong>static</strong></span> const char_type default_period_open_range_end_delimeter;
69  <span class="bold"><strong>static</strong></span> const char_type default_period_closed_range_end_delimeter;
70};</pre></div>
71<div class="refsect1" lang="en">
72<a name="id2648417"></a><h2>Description</h2>
73<p>Provides settings for the following:</p>
74<div class="itemizedlist"><ul type="disc">
75<li><p>period_separator -- default '/'</p></li>
76<li><p>period_open_start_delimeter -- default '['</p></li>
77<li><p>period_open_range_end_delimeter -- default ')'</p></li>
78<li><p>period_closed_range_end_delimeter -- default ']'</p></li>
79<li><p>display_as_open_range, display_as_closed_range -- default closed_range</p></li>
80</ul></div>
81<p>For a typical date_period, the contents of the input stream would be </p>
82<pre class="programlisting">  [2004-Jan-04/2004-Feb-01]
83   *
84</pre>
85<p>where the date format is controlled by the date facet </p>
86<div class="refsect2" lang="en">
87<a name="id2648456"></a><h3>
88<a name="period_parserconstruct-copy-destruct"></a><code class="computeroutput">period_parser</code> construct/copy/destruct</h3>
89<div class="orderedlist"><ol type="1">
90<li><pre class="literallayout"><a name="id2520377-bb"></a>period_parser(period_range_option range_option = AS_CLOSED_RANGE,
91              <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_separator = default_period_separator,
92              <span class="bold"><strong>const</strong></span> char_type *<span class="bold"><strong>const</strong></span> period_start_delimeter = default_period_start_delimeter,
93              <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,
94              <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>
95<li><pre class="literallayout"><a name="id2394256-bb"></a>period_parser(<span class="bold"><strong>const</strong></span> <a href="period_parser.html" title="Class template period_parser">period_parser</a>&lt; date_type, CharT &gt; &amp; p_parser);</pre></li>
96</ol></div>
97</div>
98<div class="refsect2" lang="en">
99<a name="id2648579"></a><h3>
100<a name="id2471763-bb"></a><code class="computeroutput">period_parser</code> public member functions</h3>
101<div class="orderedlist"><ol type="1">
102<li><pre class="literallayout"><span class="type">period_range_option</span> <a name="id2471768-bb"></a>range_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="id2471780-bb"></a>range_option(period_range_option option) ;</pre></li>
104<li><pre class="literallayout"><span class="type">collection_type</span> <a name="id2471803-bb"></a>delimiter_strings() <span class="bold"><strong>const</strong></span>;</pre></li>
105<li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2471816-bb"></a>delimiter_strings(<span class="bold"><strong>const</strong></span> string_type &amp; separator,
106                       <span class="bold"><strong>const</strong></span> string_type &amp; start_delim,
107                       <span class="bold"><strong>const</strong></span> string_type &amp; open_end_delim,
108                       <span class="bold"><strong>const</strong></span> string_type &amp; closed_end_delim) ;</pre></li>
109<li>
110<pre class="literallayout"><span class="bold"><strong>template</strong></span>&lt;<span class="bold"><strong>typename</strong></span> period_type, <span class="bold"><strong>typename</strong></span> duration_type, <span class="bold"><strong>typename</strong></span> facet_type&gt; 
111  <span class="type">period_type</span> <a name="id2468850-bb"></a>get_period(stream_itr_type &amp; sitr, stream_itr_type &amp; stream_end,
112                         std::ios_base &amp; a_ios, <span class="bold"><strong>const</strong></span> period_type &amp; p,
113                         <span class="bold"><strong>const</strong></span> duration_type &amp; dur_unit,
114                         <span class="bold"><strong>const</strong></span> facet_type &amp; facet) <span class="bold"><strong>const</strong></span>;</pre>
115<p>This generic code will parse any period using a facet to to get the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be parsed according the to setup in the passed facet parameter.</p>
116<p>The steps for parsing a period are always the same:</p>
117<div class="itemizedlist"><ul type="disc">
118<li><p>consume the start delimiter</p></li>
119<li><p>get start element</p></li>
120<li><p>consume the separator</p></li>
121<li><p>get either last or end element depending on range settings</p></li>
122<li><p>consume the end delimeter depending on range settings</p></li>
123</ul></div>
124<p>Thus for a typical date period the contents of the input stream might look like this: </p>
125<pre class="programlisting">    [March 01, 2004/June 07, 2004]   &lt;-- closed range
126    [March 01, 2004/June 08, 2004)   &lt;-- open range
127
128     *
129</pre>
130</li>
131</ol></div>
132</div>
133<div class="refsect2" lang="en">
134<a name="id2648833"></a><h3>
135<a name="id2394322-bb"></a><code class="computeroutput">period_parser</code> private member functions</h3>
136<div class="orderedlist"><ol type="1"><li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2529067-bb"></a>consume_delim(stream_itr_type &amp; sitr, stream_itr_type &amp; stream_end,
137                   <span class="bold"><strong>const</strong></span> string_type &amp; delim) <span class="bold"><strong>const</strong></span>;</pre></li></ol></div>
138</div>
139</div>
140</div>
141<table width="100%"><tr>
142<td align="left"></td>
143<td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td>
144</tr></table>
145<hr>
146<div class="spirit-nav">
147<a accesskey="p" href="period_formatter.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2394584"><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="special_values_formatter.html"><img src="images/next.png" alt="Next"></a>
148</div>
149</body>
150</html>
Note: See TracBrowser for help on using the repository browser.