1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
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">
10 <title>Boost Escaped List Separator
</title>
13 <body bgcolor=
"#FFFFFF" text=
"#000000" link=
"#0000EE" vlink=
"#551A8B" alink=
15 <h1 align=
"left"><img src=
"../../boost.png" alt=
"C++ Boost" width=
"277"
18 <h1 align=
"center">Escaped List Separator
</h1>
22 escaped_list_separator
<Char, Traits = std::char_traits
<Char
> >
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>
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>
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
42 <table border=
"1" summary=
"">
45 <p align=
"center"><strong>Escape Sequence
</strong></p>
49 <p align=
"center"><strong>Result
</strong></p>
54 <td><escape
><quote
></td>
56 <td><quote
></td>
60 <td><escape
>n
</td>
66 <td><escape
><escape
></td>
68 <td><escape
></td>
72 <p>Where
<quote
> is any character specified to be a quote
73 and
<escape
> is any character specified to be an escape character.
</p>
77 // simple_example_2.cpp
78 #include
<iostream
>
79 #include
<boost/tokenizer.hpp
>
80 #include
<string
>
84 using namespace boost;
85 string s =
"Field 1,\"putting quotes around fields, allows commas\
",Field 3";
86 tokenizer
<escaped_list_separator
<char
> > tok(s);
87 for(tokenizer
<escaped_list_separator
<char
> >::iterator beg=tok.begin(); beg!=tok.end();++beg){
88 cout
<< *beg
<< "\n";
95 <h2>Construction and Usage
</h2>
97 <p>escaped_list_separator has
2 constructors. They are as follows
</p>
99 explicit escaped_list_separator(Char e = '\\', Char c = ',',Char q = '\
"')
102 <table border="1" summary="">
105 <p align="center
"><strong>Parameter</strong></p>
109 <p align="center
"><strong>Description</strong></p>
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
127 <td>Specifies the character to use to separate the fields</td>
133 <td>Specifies the character to use for the quote.</td>
139 escaped_list_separator(string_type e, string_type c, string_type q):
142 <table border="1" summary="">
145 <p align="center
"><strong>Parameter</strong></p>
149 <p align="center
"><strong>Description</strong></p>
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
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>
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>
178 <p>To use this class, pass an object of it anywhere in the Tokenizer
179 package where a TokenizerFunction is required.</p>
183 <h2>Template Parameters</h2>
185 <table border="1" summary="">
187 <th><strong>Parameter</strong></th>
189 <th><strong>Description</strong></th>
193 <td><tt>Char</tt></td>
195 <td>The type of the elements within a token, typically
202 <td>The traits class for the Char type. This is used for comparing
203 Char's. It defaults to std::char_traits<Char></td>
211 <p><a href="tokenizerfunction.htm
">TokenizerFunction</a></p>
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>
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>
224 <p><i>Copyright © 2001 John R. Bandela</i></p>
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
229 "http://www.boost.org/LICENSE_1_0.txt
">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>