]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/tokenizer/escaped_list_separator.htm
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / tokenizer / escaped_list_separator.htm
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 Escaped List Separator</title>
11 </head>
12
13 <body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink=
14 "#FF0000">
15 <h1 align="left"><img src="../../boost.png" alt="C++ Boost" width="277"
16 height="86"></h1>
17
18 <h1 align="center">Escaped List Separator</h1>
19
20 <div align="left">
21 <pre>
22 escaped_list_separator&lt;Char, Traits = std::char_traits&lt;Char&gt; &gt;
23 </pre>
24 </div>
25
26 <p>The <tt>escaped_list_separator</tt> class is an implementation of the
27 <a href="tokenizerfunction.htm">TokenizerFunction</a>. The
28 escaped_list_separator parses a superset of the csv (comma separated value)
29 format. The examples of this formate are below. It is assumed that the
30 default characters for separator, quote, and escape are used.</p>
31
32 <p>Field 1,Field 2,Field 3<br>
33 Field 1,"Field 2, with comma",Field 3<br>
34 Field 1,Field 2 with \"embedded quote\",Field 3<br>
35 Field 1, Field 2 with \n new line,Field 3<br>
36 Field 1, Field 2 with embedded \\ ,Field 3</p>
37
38 <p>Fields are normally separated by commas. If you want to put a comma in a
39 field, you need to put quotes around it. Also 3 escape sequences are
40 supported</p>
41
42 <table border="1" summary="">
43 <tr>
44 <td>
45 <p align="center"><strong>Escape Sequence</strong></p>
46 </td>
47
48 <td>
49 <p align="center"><strong>Result</strong></p>
50 </td>
51 </tr>
52
53 <tr>
54 <td>&lt;escape&gt;&lt;quote&gt;</td>
55
56 <td>&lt;quote&gt;</td>
57 </tr>
58
59 <tr>
60 <td>&lt;escape&gt;n</td>
61
62 <td>newline</td>
63 </tr>
64
65 <tr>
66 <td>&lt;escape&gt;&lt;escape&gt;</td>
67
68 <td>&lt;escape&gt;</td>
69 </tr>
70 </table>
71
72 <p>Where &lt;quote&gt; is any character specified to be a quote
73 and&lt;escape&gt; is any character specified to be an escape character.</p>
74
75 <h2>Example</h2>
76 <pre>
77 // simple_example_2.cpp
78 #include&lt;iostream&gt;
79 #include&lt;boost/tokenizer.hpp&gt;
80 #include&lt;string&gt;
81
82 int main(){
83 using namespace std;
84 using namespace boost;
85 string s = "Field 1,\"putting quotes around fields, allows commas\",Field 3";
86 tokenizer&lt;escaped_list_separator&lt;char&gt; &gt; tok(s);
87 for(tokenizer&lt;escaped_list_separator&lt;char&gt; &gt;::iterator beg=tok.begin(); beg!=tok.end();++beg){
88 cout &lt;&lt; *beg &lt;&lt; "\n";
89 }
90 }
91 </pre>
92
93 <p>&nbsp;</p>
94
95 <h2>Construction and Usage</h2>
96
97 <p>escaped_list_separator has 2 constructors. They are as follows</p>
98 <pre>
99 explicit escaped_list_separator(Char e = '\\', Char c = ',',Char q = '\"')
100 </pre>
101
102 <table border="1" summary="">
103 <tr>
104 <td>
105 <p align="center"><strong>Parameter</strong></p>
106 </td>
107
108 <td>
109 <p align="center"><strong>Description</strong></p>
110 </td>
111 </tr>
112
113 <tr>
114 <td>e</td>
115
116 <td>Specifies the character to use for escape sequences. It defaults to
117 the C style \ (backslash). However you can override by passing in a
118 different character. An example of when you might want to do this is
119 when you have many fields which are Windows style filenames. Instead of
120 escaping out each \ in the path, you can change the escape to something
121 else.</td>
122 </tr>
123
124 <tr>
125 <td>c</td>
126
127 <td>Specifies the character to use to separate the fields</td>
128 </tr>
129
130 <tr>
131 <td>q</td>
132
133 <td>Specifies the character to use for the quote.</td>
134 </tr>
135 </table>
136
137 <p>&nbsp;</p>
138 <pre>
139 escaped_list_separator(string_type e, string_type c, string_type q):
140 </pre>
141
142 <table border="1" summary="">
143 <tr>
144 <td>
145 <p align="center"><strong>Parameter</strong></p>
146 </td>
147
148 <td>
149 <p align="center"><strong>Description</strong></p>
150 </td>
151 </tr>
152
153 <tr>
154 <td>e</td>
155
156 <td>Any character in the string e, is considered to be an escape
157 character. If an empty string is given, then there are no escape
158 characters.</td>
159 </tr>
160
161 <tr>
162 <td>c</td>
163
164 <td>Any character in the string c, is considered to be a separator. If
165 an empty string is given, then there are no separator characters.</td>
166 </tr>
167
168 <tr>
169 <td>q</td>
170
171 <td>Any character in the string q, is considered to be a quote. If an
172 empty string is given, then there are no quote characters.</td>
173 </tr>
174 </table>
175
176 <p>&nbsp;</p>
177
178 <p>To use this class, pass an object of it anywhere in the Tokenizer
179 package where a TokenizerFunction is required.</p>
180
181 <p>&nbsp;</p>
182
183 <h2>Template Parameters</h2>
184
185 <table border="1" summary="">
186 <tr>
187 <th><strong>Parameter</strong></th>
188
189 <th><strong>Description</strong></th>
190 </tr>
191
192 <tr>
193 <td><tt>Char</tt></td>
194
195 <td>The type of the elements within a token, typically
196 <tt>char</tt>.</td>
197 </tr>
198
199 <tr>
200 <td>Traits</td>
201
202 <td>The traits class for the Char type. This is used for comparing
203 Char's. It defaults to std::char_traits&lt;Char&gt;</td>
204 </tr>
205 </table>
206
207 <p>&nbsp;</p>
208
209 <h2>Model of</h2>
210
211 <p><a href="tokenizerfunction.htm">TokenizerFunction</a></p>
212
213 <p>&nbsp;</p>
214 <hr>
215
216 <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
217 "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
218 height="31" width="88"></a></p>
219
220 <p>Revised
221 <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25
222 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38518" --></p>
223
224 <p><i>Copyright &copy; 2001 John R. Bandela</i></p>
225
226 <p><i>Distributed under the Boost Software License, Version 1.0. (See
227 accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
228 copy at <a href=
229 "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
230 </body>
231 </html>