Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/tokenizer/token_iterator.htm @ 13

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

added boost

File size: 4.2 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Type"
5content="text/html; charset=iso-8859-1">
6<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
7<title>Boost Token Iterator</title>
8<!--
9  -- Copyright © John Bandela 2001
10  --
11  -- Permission to use, copy, modify, distribute and sell this software
12  -- and its documentation for any purpose is hereby granted without fee,
13  -- provided that the above copyright notice appears in all copies and
14  -- that both that copyright notice and this permission notice appear
15  -- in supporting documentation.  Jeremy Siek makes no
16  -- representations about the suitability of this software for any
17  -- purpose.  It is provided "as is" without express or implied warranty.
18  -->
19</head>
20
21<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
22vlink="#551A8B" alink="#FF0000">
23
24<p><img src="../../boost.png" alt="C++ Boost" width="277"
25height="86"> <br>
26</p>
27
28<h1 align="center">Token Iterator</h1>
29
30<pre>
31template &lt;
32        class TokenizerFunc = char_delimiters_separator&lt;char&gt;,
33        class Iterator = std::string::const_iterator,
34        class Type = std::string
35&gt;
36class token_iterator_generator </pre>
37
38<pre>template&lt;class Type, class Iterator, class TokenizerFunc&gt;
39typename token_iterator_generator&lt;TokenizerFunc,Iterator,Type&gt;::type
40make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc&amp; fun)
41
42</pre>
43
44<p>The token iterator serves to provide an iterator view of the
45tokens in a parsed sequence.</p>
46
47<h2>Example</h2>
48
49<pre>
50/// simple_example_5.cpp
51#include&lt;iostream&gt;
52#include&lt;boost/token_iterator.hpp&gt;
53#include&lt;string&gt;
54
55int main(){
56   using namespace std;
57   using namespace boost;
58   string s = &quot;12252001&quot;;
59   int offsets[] = {2,2,4};
60   offset_separator f(offsets, offsets+3);
61   typedef token_iterator_generator&lt;offset_separator&gt;::type Iter;
62   Iter beg = make_token_iterator&lt;string&gt;(s.begin(),s.end(),f);
63   Iter end = make_token_iterator&lt;string&gt;(s.end(),s.end(),f);
64   // The above statement could also have been what is below
65   // Iter end;
66   for(;beg!=end;++beg){
67     cout &lt;&lt; *beg &lt;&lt; &quot;\n&quot;;
68   }
69}
70</pre>
71
72<pre>
73</pre>
74
75<p>&nbsp;</p>
76
77<h3>Template Parameters</h3>
78
79<table border="1">
80    <tr>
81        <th>Parameter</th>
82        <th>Description</th>
83    </tr>
84    <tr>
85        <td><tt>TokenizerFunc</tt></td>
86        <td>The TokenizerFunction used to parse the sequence.</td>
87    </tr>
88    <tr>
89        <td><tt>Iterator</tt></td>
90        <td>The type of the iterator the specifies the sequence.</td>
91    </tr>
92    <tr>
93        <td><tt>Type</tt></td>
94        <td>The type of the token, typically string.</td>
95    </tr>
96</table>
97
98<h2>Model of</h2>
99
100<p>The category of Iterator, up to and including Forward Iterator.
101Anything higher will get scaled down to Forward Iterator.</p>
102
103<h2>Related Types</h2>
104
105<table border="1">
106    <tr>
107        <td><p align="center"><strong>Type</strong></p>
108        </td>
109        <td><p align="center"><strong>Remarks</strong></p>
110        </td>
111    </tr>
112    <tr>
113        <td>token_iterator_generator::type</td>
114        <td>The type of the token iterator.</td>
115    </tr>
116</table>
117
118<h2>Creation</h2>
119
120<pre>template&lt;class Type, class Iterator, class TokenizerFunc&gt;
121typename token_iterator_generator&lt;TokenizerFunc,Iterator,Type&gt;::type
122make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc&amp; fun)</pre>
123
124<table border="1">
125    <tr>
126        <td><p align="center"><strong>Parameter</strong></p>
127        </td>
128        <td><p align="center"><strong>Description</strong></p>
129        </td>
130    </tr>
131    <tr>
132        <td>begin</td>
133        <td>The beginning of the sequence to be parsed.</td>
134    </tr>
135    <tr>
136        <td>end</td>
137        <td>Past the end of the sequence to be parsed.</td>
138    </tr>
139    <tr>
140        <td>fun</td>
141        <td>A functor that is a model of TokenizerFunction</td>
142    </tr>
143</table>
144
145<p>&nbsp;</p>
146
147<hr>
148
149<p>© Copyright John R. Bandela 2001. Permission to copy, use,
150modify, sell and distribute this document is granted provided
151this copyright notice appears in all copies. This document is
152provided &quot;as is&quot; without express or implied warranty,
153and with no claim as to its suitability for any purpose.</p>
154</body>
155</html>
Note: See TracBrowser for help on using the repository browser.