1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <meta http-equiv="Content-Language" content="en-us"> |
---|
6 | <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
---|
7 | <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> |
---|
8 | <meta name="ProgId" content="FrontPage.Editor.Document"> |
---|
9 | |
---|
10 | <title>Boost Token Iterator</title> |
---|
11 | </head> |
---|
12 | |
---|
13 | <body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink= |
---|
14 | "#FF0000"> |
---|
15 | <p><img src="../../boost.png" alt="C++ Boost" width="277" height= |
---|
16 | "86"><br></p> |
---|
17 | |
---|
18 | <h1 align="center">Token Iterator</h1> |
---|
19 | <pre> |
---|
20 | template < |
---|
21 | class TokenizerFunc = char_delimiters_separator<char>, |
---|
22 | class Iterator = std::string::const_iterator, |
---|
23 | class Type = std::string |
---|
24 | > |
---|
25 | class token_iterator_generator |
---|
26 | </pre> |
---|
27 | <pre> |
---|
28 | template<class Type, class Iterator, class TokenizerFunc> |
---|
29 | typename token_iterator_generator<TokenizerFunc,Iterator,Type>::type |
---|
30 | make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc& fun) |
---|
31 | |
---|
32 | </pre> |
---|
33 | |
---|
34 | <p>The token iterator serves to provide an iterator view of the tokens in a |
---|
35 | parsed sequence.</p> |
---|
36 | |
---|
37 | <h2>Example</h2> |
---|
38 | <pre> |
---|
39 | /// simple_example_5.cpp |
---|
40 | #include<iostream> |
---|
41 | #include<boost/token_iterator.hpp> |
---|
42 | #include<string> |
---|
43 | |
---|
44 | int main(){ |
---|
45 | using namespace std; |
---|
46 | using namespace boost; |
---|
47 | string s = "12252001"; |
---|
48 | int offsets[] = {2,2,4}; |
---|
49 | offset_separator f(offsets, offsets+3); |
---|
50 | typedef token_iterator_generator<offset_separator>::type Iter; |
---|
51 | Iter beg = make_token_iterator<string>(s.begin(),s.end(),f); |
---|
52 | Iter end = make_token_iterator<string>(s.end(),s.end(),f); |
---|
53 | // The above statement could also have been what is below |
---|
54 | // Iter end; |
---|
55 | for(;beg!=end;++beg){ |
---|
56 | cout << *beg << "\n"; |
---|
57 | } |
---|
58 | } |
---|
59 | </pre> |
---|
60 | |
---|
61 | <p> </p> |
---|
62 | |
---|
63 | <h3>Template Parameters</h3> |
---|
64 | |
---|
65 | <table border="1" summary=""> |
---|
66 | <tr> |
---|
67 | <th>Parameter</th> |
---|
68 | |
---|
69 | <th>Description</th> |
---|
70 | </tr> |
---|
71 | |
---|
72 | <tr> |
---|
73 | <td><tt>TokenizerFunc</tt></td> |
---|
74 | |
---|
75 | <td>The TokenizerFunction used to parse the sequence.</td> |
---|
76 | </tr> |
---|
77 | |
---|
78 | <tr> |
---|
79 | <td><tt>Iterator</tt></td> |
---|
80 | |
---|
81 | <td>The type of the iterator the specifies the sequence.</td> |
---|
82 | </tr> |
---|
83 | |
---|
84 | <tr> |
---|
85 | <td><tt>Type</tt></td> |
---|
86 | |
---|
87 | <td>The type of the token, typically string.</td> |
---|
88 | </tr> |
---|
89 | </table> |
---|
90 | |
---|
91 | <h2>Model of</h2> |
---|
92 | |
---|
93 | <p>The category of Iterator, up to and including Forward Iterator. Anything |
---|
94 | higher will get scaled down to Forward Iterator.</p> |
---|
95 | |
---|
96 | <h2>Related Types</h2> |
---|
97 | |
---|
98 | <table border="1" summary=""> |
---|
99 | <tr> |
---|
100 | <td> |
---|
101 | <p align="center"><strong>Type</strong></p> |
---|
102 | </td> |
---|
103 | |
---|
104 | <td> |
---|
105 | <p align="center"><strong>Remarks</strong></p> |
---|
106 | </td> |
---|
107 | </tr> |
---|
108 | |
---|
109 | <tr> |
---|
110 | <td>token_iterator_generator::type</td> |
---|
111 | |
---|
112 | <td>The type of the token iterator.</td> |
---|
113 | </tr> |
---|
114 | </table> |
---|
115 | |
---|
116 | <h2>Creation</h2> |
---|
117 | <pre> |
---|
118 | template<class Type, class Iterator, class TokenizerFunc> |
---|
119 | typename token_iterator_generator<TokenizerFunc,Iterator,Type>::type |
---|
120 | make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc& fun) |
---|
121 | </pre> |
---|
122 | |
---|
123 | <table border="1" summary=""> |
---|
124 | <tr> |
---|
125 | <td> |
---|
126 | <p align="center"><strong>Parameter</strong></p> |
---|
127 | </td> |
---|
128 | |
---|
129 | <td> |
---|
130 | <p align="center"><strong>Description</strong></p> |
---|
131 | </td> |
---|
132 | </tr> |
---|
133 | |
---|
134 | <tr> |
---|
135 | <td>begin</td> |
---|
136 | |
---|
137 | <td>The beginning of the sequence to be parsed.</td> |
---|
138 | </tr> |
---|
139 | |
---|
140 | <tr> |
---|
141 | <td>end</td> |
---|
142 | |
---|
143 | <td>Past the end of the sequence to be parsed.</td> |
---|
144 | </tr> |
---|
145 | |
---|
146 | <tr> |
---|
147 | <td>fun</td> |
---|
148 | |
---|
149 | <td>A functor that is a model of TokenizerFunction</td> |
---|
150 | </tr> |
---|
151 | </table> |
---|
152 | |
---|
153 | <p> </p> |
---|
154 | <hr> |
---|
155 | |
---|
156 | <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
---|
157 | "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" |
---|
158 | height="31" width="88"></a></p> |
---|
159 | |
---|
160 | <p>Revised |
---|
161 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 |
---|
162 | December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38518" --></p> |
---|
163 | |
---|
164 | <p><i>Copyright © 2001 John R. Bandela</i></p> |
---|
165 | |
---|
166 | <p><i>Distributed under the Boost Software License, Version 1.0. (See |
---|
167 | accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
---|
168 | copy at <a href= |
---|
169 | "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
---|
170 | </body> |
---|
171 | </html> |
---|