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 Tokenizer Class</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">Tokenizer Class</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 tokenizer |
---|
26 | </pre> |
---|
27 | |
---|
28 | <p>The tokenizer class provides a container view of a series of tokens |
---|
29 | contained in a sequence. You set the sequence to parse and the |
---|
30 | TokenizerFunction to use to parse the sequence either upon construction or |
---|
31 | using the assign member function. Note: No parsing is actually done upon |
---|
32 | construction. Parsing is done on demand as the tokens are accessed via the |
---|
33 | iterator provided by begin.</p> |
---|
34 | |
---|
35 | <h2>Example</h2> |
---|
36 | <pre> |
---|
37 | // simple_example_1.cpp |
---|
38 | #include<iostream> |
---|
39 | #include<boost/tokenizer.hpp> |
---|
40 | #include<string> |
---|
41 | |
---|
42 | int main(){ |
---|
43 | using namespace std; |
---|
44 | using namespace boost; |
---|
45 | string s = "This is, a test"; |
---|
46 | tokenizer<> tok(s); |
---|
47 | for(tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){ |
---|
48 | cout << *beg << "\n"; |
---|
49 | } |
---|
50 | } |
---|
51 | </pre> |
---|
52 | |
---|
53 | <p> </p> |
---|
54 | |
---|
55 | <h3>Template Parameters</h3> |
---|
56 | |
---|
57 | <table border="1" summary=""> |
---|
58 | <tr> |
---|
59 | <th>Parameter</th> |
---|
60 | |
---|
61 | <th>Description</th> |
---|
62 | </tr> |
---|
63 | |
---|
64 | <tr> |
---|
65 | <td><tt>TokenizerFunc</tt></td> |
---|
66 | |
---|
67 | <td>The TokenizerFunction used to parse the sequence.</td> |
---|
68 | </tr> |
---|
69 | |
---|
70 | <tr> |
---|
71 | <td><tt>Iterator</tt></td> |
---|
72 | |
---|
73 | <td>The type of the iterator the specifies the sequence.</td> |
---|
74 | </tr> |
---|
75 | |
---|
76 | <tr> |
---|
77 | <td><tt>Type</tt></td> |
---|
78 | |
---|
79 | <td>The type of the token, typically string.</td> |
---|
80 | </tr> |
---|
81 | </table> |
---|
82 | |
---|
83 | <p> </p> |
---|
84 | |
---|
85 | <h2>Related Types</h2> |
---|
86 | |
---|
87 | <table border="1" summary=""> |
---|
88 | <tr> |
---|
89 | <td> |
---|
90 | <p align="center"><strong>Type</strong></p> |
---|
91 | </td> |
---|
92 | |
---|
93 | <td> |
---|
94 | <p align="center"><strong>Remarks</strong></p> |
---|
95 | </td> |
---|
96 | </tr> |
---|
97 | |
---|
98 | <tr> |
---|
99 | <td>iterator</td> |
---|
100 | |
---|
101 | <td>The type returned by begin and end. Note: the category of iterator |
---|
102 | will be at most ForwardIterator. It will be InputIterator if the |
---|
103 | Iterator template parameter is an InputIterator. For any other |
---|
104 | category, it will be ForwardIterator.</td> |
---|
105 | </tr> |
---|
106 | |
---|
107 | <tr> |
---|
108 | <td>const_iterator</td> |
---|
109 | |
---|
110 | <td>Same type as iterator.</td> |
---|
111 | </tr> |
---|
112 | |
---|
113 | <tr> |
---|
114 | <td>value_type</td> |
---|
115 | |
---|
116 | <td>Same type as the template parameter Type</td> |
---|
117 | </tr> |
---|
118 | |
---|
119 | <tr> |
---|
120 | <td>reference</td> |
---|
121 | |
---|
122 | <td>Same type as value_type&</td> |
---|
123 | </tr> |
---|
124 | |
---|
125 | <tr> |
---|
126 | <td>const_reference</td> |
---|
127 | |
---|
128 | <td>Same type as const reference</td> |
---|
129 | </tr> |
---|
130 | |
---|
131 | <tr> |
---|
132 | <td>pointer</td> |
---|
133 | |
---|
134 | <td>Same type as value_type*</td> |
---|
135 | </tr> |
---|
136 | |
---|
137 | <tr> |
---|
138 | <td>const_pointer</td> |
---|
139 | |
---|
140 | <td>Same type as const pointer</td> |
---|
141 | </tr> |
---|
142 | |
---|
143 | <tr> |
---|
144 | <td>size_type</td> |
---|
145 | |
---|
146 | <td>void</td> |
---|
147 | </tr> |
---|
148 | |
---|
149 | <tr> |
---|
150 | <td>difference_type</td> |
---|
151 | |
---|
152 | <td>void</td> |
---|
153 | </tr> |
---|
154 | </table> |
---|
155 | |
---|
156 | <p> </p> |
---|
157 | |
---|
158 | <h2>Construction and Member Functions</h2> |
---|
159 | <pre> |
---|
160 | tokenizer(Iterator first, Iterator last,const TokenizerFunc& f = TokenizerFunc()) |
---|
161 | |
---|
162 | template<class Container> |
---|
163 | tokenizer(const Container& c,const TokenizerFunc& f = TokenizerFunc()) |
---|
164 | |
---|
165 | void assign(Iterator first, Iterator last) |
---|
166 | |
---|
167 | void assign(Iterator first, Iterator last, const TokenizerFunc& f) |
---|
168 | |
---|
169 | template<class Container> |
---|
170 | void assign(const Container& c) |
---|
171 | |
---|
172 | template<class Container> |
---|
173 | void assign(const Container& c, const TokenizerFunc& f) |
---|
174 | |
---|
175 | iterator begin() const |
---|
176 | |
---|
177 | iterator end() const |
---|
178 | </pre> |
---|
179 | |
---|
180 | <table border="1" summary=""> |
---|
181 | <tr> |
---|
182 | <td> |
---|
183 | <p align="center"><strong>Parameter</strong></p> |
---|
184 | </td> |
---|
185 | |
---|
186 | <td> |
---|
187 | <p align="center"><strong>Description</strong></p> |
---|
188 | </td> |
---|
189 | </tr> |
---|
190 | |
---|
191 | <tr> |
---|
192 | <td>c</td> |
---|
193 | |
---|
194 | <td>A container that contains the sequence to parse. Note: c.begin() |
---|
195 | and c.end() must be convertible to the template parameter |
---|
196 | Iterator.</td> |
---|
197 | </tr> |
---|
198 | |
---|
199 | <tr> |
---|
200 | <td>f</td> |
---|
201 | |
---|
202 | <td>A functor that is a model of TokenizerFunction that will be used to |
---|
203 | parse the sequence.</td> |
---|
204 | </tr> |
---|
205 | |
---|
206 | <tr> |
---|
207 | <td>first</td> |
---|
208 | |
---|
209 | <td>The iterator that represents the beginning position in the sequence |
---|
210 | to be parsed.</td> |
---|
211 | </tr> |
---|
212 | |
---|
213 | <tr> |
---|
214 | <td>last</td> |
---|
215 | |
---|
216 | <td>The iterator that represents the past the end position in the |
---|
217 | sequence to be parsed.</td> |
---|
218 | </tr> |
---|
219 | </table> |
---|
220 | |
---|
221 | <p> </p> |
---|
222 | <hr> |
---|
223 | |
---|
224 | <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
---|
225 | "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" |
---|
226 | height="31" width="88"></a></p> |
---|
227 | |
---|
228 | <p>Revised |
---|
229 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38518" --></p> |
---|
230 | |
---|
231 | <p><i>Copyright © 2001 John R. Bandela</i></p> |
---|
232 | |
---|
233 | <p><i>Distributed under the Boost Software License, Version 1.0. (See |
---|
234 | accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
---|
235 | copy at <a href= |
---|
236 | "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
---|
237 | </body> |
---|
238 | </html> |
---|