Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added boost

File size: 9.8 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Struct template string_parse_tree</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#id2393421" title="Header &lt;boost/date_time/string_parse_tree.hpp&gt;">
9<link rel="prev" href="parse_match_result.html" title="Struct template parse_match_result">
10<link rel="next" href="gather_month_strings.html" title="Function template gather_month_strings">
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="parse_match_result.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2393421"><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="gather_month_strings.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="string_parse_tree"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Struct template string_parse_tree</span></h2>
29<p>boost::date_time::string_parse_tree &#8212; Recursive data structure to allow efficient parsing of various strings. </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> charT&gt; 
33<span class="bold"><strong>struct</strong></span> string_parse_tree {
34  <span class="emphasis"><em>// types</em></span>
35  <span class="bold"><strong>typedef</strong></span> std::multimap&lt; charT, <a href="string_parse_tree.html" title="Struct template string_parse_tree">string_parse_tree</a> &gt; ptree_coll;             
36  <span class="bold"><strong>typedef</strong></span> ptree_coll::value_type                    value_type;             
37  <span class="bold"><strong>typedef</strong></span> ptree_coll::iterator                      iterator;               
38  <span class="bold"><strong>typedef</strong></span> ptree_coll::const_iterator                const_iterator;         
39  <span class="bold"><strong>typedef</strong></span> std::basic_string&lt; charT &gt;                string_type;            
40  <span class="bold"><strong>typedef</strong></span> std::vector&lt; std::basic_string&lt; charT &gt; &gt; collection_type;        
41  <span class="bold"><strong>typedef</strong></span> parse_match_result&lt; charT &gt;               parse_match_result_type;
42
43  <span class="emphasis"><em>// <a href="string_parse_tree.html#string_parse_treeconstruct-copy-destruct">construct/copy/destruct</a></em></span>
44  <a href="string_parse_tree.html#id2481266-bb">string_parse_tree</a>(collection_type, <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>int</strong></span> = 0);
45  <a href="string_parse_tree.html#id2472689-bb">string_parse_tree</a>(<span class="bold"><strong>short</strong></span> = -1);
46
47  <span class="emphasis"><em>// <a href="string_parse_tree.html#id2454061-bb">public member functions</a></em></span>
48  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="string_parse_tree.html#id2454065-bb">insert</a>(<span class="bold"><strong>const</strong></span> string_type &amp;, <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>short</strong></span>) ;
49  <span class="type"><span class="bold"><strong>short</strong></span></span> <a href="string_parse_tree.html#id2405862-bb">match</a>(std::istreambuf_iterator&lt; charT &gt; &amp;,
50              std::istreambuf_iterator&lt; charT &gt; &amp;, parse_match_result_type &amp;,
51              <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>int</strong></span> &amp;) <span class="bold"><strong>const</strong></span>;
52  <span class="type">parse_match_result_type</span> 
53  <a href="string_parse_tree.html#id2481352-bb">match</a>(std::istreambuf_iterator&lt; charT &gt; &amp;,
54        std::istreambuf_iterator&lt; charT &gt; &amp;) <span class="bold"><strong>const</strong></span>;
55  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="string_parse_tree.html#id2481396-bb">printme</a>(std::ostream &amp;, <span class="bold"><strong>int</strong></span> &amp;) ;
56  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="string_parse_tree.html#id2481209-bb">print</a>(std::ostream &amp;) ;
57  <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="string_parse_tree.html#id2481232-bb">printmatch</a>(std::ostream &amp;, charT) ;
58
59  ptree_coll m_next_chars;
60  short m_value;
61};</pre></div>
62<div class="refsect1" lang="en">
63<a name="id2650924"></a><h2>Description</h2>
64<p>This class provides a quick lookup by building what amounts to a tree data structure. It also features a match function which can can handle nasty input interators by caching values as it recurses the tree so that it can backtrack as needed. </p>
65<div class="refsect2" lang="en">
66<a name="id2650934"></a><h3>
67<a name="string_parse_treeconstruct-copy-destruct"></a><code class="computeroutput">string_parse_tree</code> construct/copy/destruct</h3>
68<div class="orderedlist"><ol type="1">
69<li>
70<pre class="literallayout"><a name="id2481266-bb"></a>string_parse_tree(collection_type names, <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>int</strong></span> starting_point = 0);</pre>
71<p>Parameter "starting_point" desingates where the numbering begins. A starting_point of zero will start the numbering at zero (Sun=0, Mon=1, ...) were a starting_point of one starts the numbering at one (Jan=1, Feb=2, ...). The default is zero, negative vaules are not allowed </p>
72</li>
73<li><pre class="literallayout"><a name="id2472689-bb"></a>string_parse_tree(<span class="bold"><strong>short</strong></span> value = -1);</pre></li>
74</ol></div>
75</div>
76<div class="refsect2" lang="en">
77<a name="id2651005"></a><h3>
78<a name="id2454061-bb"></a><code class="computeroutput">string_parse_tree</code> public member functions</h3>
79<div class="orderedlist"><ol type="1">
80<li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2454065-bb"></a>insert(<span class="bold"><strong>const</strong></span> string_type &amp; s, <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>short</strong></span> value) ;</pre></li>
81<li>
82<pre class="literallayout"><span class="type"><span class="bold"><strong>short</strong></span></span> <a name="id2405862-bb"></a>match(std::istreambuf_iterator&lt; charT &gt; &amp; sitr,
83            std::istreambuf_iterator&lt; charT &gt; &amp; stream_end,
84            parse_match_result_type &amp; result, <span class="bold"><strong>unsigned</strong></span> <span class="bold"><strong>int</strong></span> &amp; level) <span class="bold"><strong>const</strong></span>;</pre>
85<p>Must check match_results::has_remaining() after match() is called. This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream).</p>
86<p>A parse_match_result that has been returned from a failed match attempt can be sent in to the match function of a different string_parse_tree to attempt a match there. Use the iterators for the partially consumed stream, the parse_match_result object, and '0' for the level parameter. </p>
87</li>
88<li>
89<pre class="literallayout"><span class="type">parse_match_result_type</span> 
90<a name="id2481352-bb"></a>match(std::istreambuf_iterator&lt; charT &gt; &amp; sitr,
91      std::istreambuf_iterator&lt; charT &gt; &amp; stream_end) <span class="bold"><strong>const</strong></span>;</pre>
92<p>Must check match_results::has_remaining() after match() is called. This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream). </p>
93</li>
94<li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2481396-bb"></a>printme(std::ostream &amp; os, <span class="bold"><strong>int</strong></span> &amp; level) ;</pre></li>
95<li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2481209-bb"></a>print(std::ostream &amp; os) ;</pre></li>
96<li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2481232-bb"></a>printmatch(std::ostream &amp; os, charT c) ;</pre></li>
97</ol></div>
98</div>
99</div>
100</div>
101<table width="100%"><tr>
102<td align="left"></td>
103<td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td>
104</tr></table>
105<hr>
106<div class="spirit-nav">
107<a accesskey="p" href="parse_match_result.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2393421"><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="gather_month_strings.html"><img src="images/next.png" alt="Next"></a>
108</div>
109</body>
110</html>
Note: See TracBrowser for help on using the repository browser.