| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| |
| <html> |
| <head> |
| <meta http-equiv="Content-Language" content="en-us"> |
| <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
| <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> |
| <meta name="ProgId" content="FrontPage.Editor.Document"> |
| |
| <title>Boost Token Iterator</title> |
| </head> |
| |
| <body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink= |
| "#FF0000"> |
| <p><img src="../../boost.png" alt="C++ Boost" width="277" height= |
| "86"><br></p> |
| |
| <h1 align="center">Token Iterator</h1> |
| <pre> |
| template < |
| class TokenizerFunc = char_delimiters_separator<char>, |
| class Iterator = std::string::const_iterator, |
| class Type = std::string |
| > |
| class token_iterator_generator |
| </pre> |
| <pre> |
| template<class Type, class Iterator, class TokenizerFunc> |
| typename token_iterator_generator<TokenizerFunc,Iterator,Type>::type |
| make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc& fun) |
| |
| </pre> |
| |
| <p>The token iterator serves to provide an iterator view of the tokens in a |
| parsed sequence.</p> |
| |
| <h2>Example</h2> |
| <pre> |
| /// simple_example_5.cpp |
| #include<iostream> |
| #include<boost/token_iterator.hpp> |
| #include<string> |
| |
| int main(){ |
| using namespace std; |
| using namespace boost; |
| string s = "12252001"; |
| int offsets[] = {2,2,4}; |
| offset_separator f(offsets, offsets+3); |
| typedef token_iterator_generator<offset_separator>::type Iter; |
| Iter beg = make_token_iterator<string>(s.begin(),s.end(),f); |
| Iter end = make_token_iterator<string>(s.end(),s.end(),f); |
| // The above statement could also have been what is below |
| // Iter end; |
| for(;beg!=end;++beg){ |
| cout << *beg << "\n"; |
| } |
| } |
| </pre> |
| |
| <p> </p> |
| |
| <h3>Template Parameters</h3> |
| |
| <table border="1" summary=""> |
| <tr> |
| <th>Parameter</th> |
| |
| <th>Description</th> |
| </tr> |
| |
| <tr> |
| <td><tt>TokenizerFunc</tt></td> |
| |
| <td>The TokenizerFunction used to parse the sequence.</td> |
| </tr> |
| |
| <tr> |
| <td><tt>Iterator</tt></td> |
| |
| <td>The type of the iterator the specifies the sequence.</td> |
| </tr> |
| |
| <tr> |
| <td><tt>Type</tt></td> |
| |
| <td>The type of the token, typically string.</td> |
| </tr> |
| </table> |
| |
| <h2>Model of</h2> |
| |
| <p>The category of Iterator, up to and including Forward Iterator. Anything |
| higher will get scaled down to Forward Iterator.</p> |
| |
| <h2>Related Types</h2> |
| |
| <table border="1" summary=""> |
| <tr> |
| <td> |
| <p align="center"><strong>Type</strong></p> |
| </td> |
| |
| <td> |
| <p align="center"><strong>Remarks</strong></p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td>token_iterator_generator::type</td> |
| |
| <td>The type of the token iterator.</td> |
| </tr> |
| </table> |
| |
| <h2>Creation</h2> |
| <pre> |
| template<class Type, class Iterator, class TokenizerFunc> |
| typename token_iterator_generator<TokenizerFunc,Iterator,Type>::type |
| make_token_iterator(Iterator begin, Iterator end,const TokenizerFunc& fun) |
| </pre> |
| |
| <table border="1" summary=""> |
| <tr> |
| <td> |
| <p align="center"><strong>Parameter</strong></p> |
| </td> |
| |
| <td> |
| <p align="center"><strong>Description</strong></p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td>begin</td> |
| |
| <td>The beginning of the sequence to be parsed.</td> |
| </tr> |
| |
| <tr> |
| <td>end</td> |
| |
| <td>Past the end of the sequence to be parsed.</td> |
| </tr> |
| |
| <tr> |
| <td>fun</td> |
| |
| <td>A functor that is a model of TokenizerFunction</td> |
| </tr> |
| </table> |
| |
| <p> </p> |
| <hr> |
| |
| <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
| "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional" |
| height="31" width="88"></a></p> |
| |
| <p>Revised |
| <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 |
| December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38518" --></p> |
| |
| <p><i>Copyright © 2001 John R. Bandela</i></p> |
| |
| <p><i>Distributed under the Boost Software License, Version 1.0. (See |
| accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
| copy at <a href= |
| "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
| </body> |
| </html> |