Escaped List Separatorescaped_list_separator<Char, Traits = std::char_traits<Char> > The escaped_list_separator class is an implementation of the TokenizerFunction. The escaped_list_separator parses a superset of the csv (comma separated value) format. The examples of this formate are below. It is assumed that the default characters for separator, quote, and escape are used. Field 1,Field 2,Field 3 Fields are normally separated by commas. If you want to put a comma in a field, you need to put quotes around it. Also 3 escape sequences are supported
Where <quote> is any character specified to be a quote and<escape> is any character specified to be an escape character. Example// simple_example_2.cpp #include<iostream> #include<boost/tokenizer.hpp> #include<string> int main(){ using namespace std; using namespace boost; string s = "Field 1,\"putting quotes around fields, allows commas\",Field 3"; tokenizer<escaped_list_separator<char> > tok(s); for(tokenizer<escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg){ cout << *beg << "\n"; } }
Construction and Usageescaped_list_separator has 2 constructors. They are as follows explicit escaped_list_separator(Char e = '\\', Char c = ',',Char q = '\"')
escaped_list_separator(string_type e, string_type c, string_type q):
To use this class, pass an object of it anywhere in the Tokenizer package where a TokenizerFunction is required.
Template Parameters
Model of
Revised 25 December, 2006 Copyright © 2001 John R. Bandela Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |