Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/tokenizer/offset_separator.htm @ 35

Last change on this file since 35 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.3 KB
Line 
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 Offset Separator</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">Offset Separator</h1>
19  <pre>
20class offset_separator
21</pre>
22
23  <p>The <tt>offset_separator</tt> class is an implementation of the <a href=
24  "tokenizerfunction.htm">TokenizerFunction</a> concept that can be used with
25  the <a href="tokenizer.htm">tokenizer</a> class to break text up into
26  tokens. The <tt>offset_separator</tt> breaks a sequence of <tt>Char</tt>'s
27  into strings based on a sequence of offsets. For example, if you had the
28  string "12252001" and offsets (2,2,4) it would break the string into 12 25
29  2001. Here is an example.</p>
30
31  <h2>Example</h2>
32  <pre>
33// simple_example_3.cpp
34#include&lt;iostream&gt;
35#include&lt;boost/tokenizer.hpp&gt;
36#include&lt;string&gt;
37
38int main(){
39   using namespace std;
40   using namespace boost;
41   string s = "12252001";
42   int offsets[] = {2,2,4};
43   offset_separator f(offsets, offsets+3);
44   tokenizer&lt;offset_separator&gt; tok(s,f);
45   for(tokenizer&lt;offset_separator&gt;::iterator beg=tok.begin(); beg!=tok.end();++beg){
46     cout &lt;&lt; *beg &lt;&lt; "\n";
47   }
48}
49</pre>
50
51  <p>&nbsp;</p>
52
53  <h2>Construction and Usage</h2>
54
55  <p>The offset_separator has 1 constructor of interest. (The default
56  constructor is just there to make some compilers happy). The declaration is
57  below</p>
58  <pre>
59template&lt;typename Iter&gt;
60offset_separator(Iter begin,Iter end,bool bwrapoffsets = true, bool breturnpartiallast = true)
61</pre>
62
63  <table border="1" summary="">
64    <tr>
65      <td>
66        <p align="center"><strong>Parameter</strong></p>
67      </td>
68
69      <td>
70        <p align="center"><strong>Description</strong></p>
71      </td>
72    </tr>
73
74    <tr>
75      <td>begin, end</td>
76
77      <td>Specify the sequence of integer offsets.</td>
78    </tr>
79
80    <tr>
81      <td>bwrapoffsets</td>
82
83      <td>Tells whether to wrap around to the beginning of the offsets when
84      the all the offsets have been used. For example the string
85      "1225200101012002" with offsets (2,2,4) with bwrapoffsets to true,
86      would parse to 12 25 2001 01 01 2002. With bwrapoffsets to false, it
87      would parse to 12 25 2001 and then stop because all the offsets have
88      been used.</td>
89    </tr>
90
91    <tr>
92      <td>breturnpartiallast</td>
93
94      <td>Tells whether, when the parsed sequence terminates before yielding
95      the number of characters in the current offset, to create a token with
96      what was parsed, or to ignore it. For example the string "122501" with
97      offsets (2,2,4) with breturnpartiallast set to true will parse to 12 25
98      01. With it set to false, it will parse to 12 25 and then will stop
99      because there are only 2 characters left in the sequence instead of the
100      4 that should have been there.</td>
101    </tr>
102  </table>
103
104  <p>To use this class, pass an object of it anywhere a TokenizerFunction is
105  required. If you default constructruct the object, it will just return
106  every character in the parsed sequence as a token. (ie it defaults to an
107  offset of 1, and bwrapoffsets is true).</p>
108
109  <p>&nbsp;</p>
110
111  <h2>Model of</h2>
112
113  <p><a href="tokenizerfunction.htm">TokenizerFunction</a></p>
114  <hr>
115
116  <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
117  "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
118  height="31" width="88"></a></p>
119
120  <p>Revised
121  <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25
122  December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38518" --></p>
123
124  <p><i>Copyright &copy; 2001 John R. Bandela</i></p>
125
126  <p><i>Distributed under the Boost Software License, Version 1.0. (See
127  accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
128  copy at <a href=
129  "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
130</body>
131</html>
Note: See TracBrowser for help on using the repository browser.