From 290c4d3e67e7d4cb3acc015000b4a7ae5fed270b Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 2 Oct 2015 12:19:09 +0100 Subject: [PATCH] csv_grammar - handle 'quote' parameter dynamically --- include/mapnik/csv/csv_grammar.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/mapnik/csv/csv_grammar.hpp b/include/mapnik/csv/csv_grammar.hpp index 2bd0f5257..a07c4a6a8 100644 --- a/include/mapnik/csv/csv_grammar.hpp +++ b/include/mapnik/csv/csv_grammar.hpp @@ -36,13 +36,14 @@ using csv_line = std::vector; using csv_data = std::vector; template -struct csv_line_grammar : qi::grammar +struct csv_line_grammar : qi::grammar { csv_line_grammar() : csv_line_grammar::base_type(line) { using namespace qi; qi::_a_type _a; qi::_r1_type _r1; + qi::_r2_type _r2; qi::lit_type lit; //qi::eol_type eol; qi::_1_type _1; @@ -62,21 +63,21 @@ struct csv_line_grammar : qi::grammar> quoted | *(char_ - (lit(_r1) /*| eol*/)) + column = -omit[char_("\n\r")] >> quoted(_r2) | *(char_ - (lit(_r1) /*| eol*/)) ; - quoted = omit[char_("\"'")[_a = _1]] > text(_a) > -lit(_a) + quoted = omit[char_(_r1)[_a = _1]] > text(_a) > -lit(_a) ; text = *(unesc_char | (char_ - char_(_r1))) ; BOOST_SPIRIT_DEBUG_NODES((line)(column)(quoted)); } private: - qi::rule line; - qi::rule column; // no-skip + qi::rule line; + qi::rule column; // no-skip qi::rule text; - qi::rule, csv_value()> quoted; + qi::rule, csv_value(char)> quoted; qi::symbols unesc_char; };