diff --git a/benchmark/test_getline.cpp b/benchmark/test_getline.cpp index 1791b06cf..ed21c0421 100644 --- a/benchmark/test_getline.cpp +++ b/benchmark/test_getline.cpp @@ -1,7 +1,7 @@ #include "bench_framework.hpp" -#include -#include -#include "../plugins/input/csv/csv_utils.hpp" +#include "../plugins/input/csv/csv_getline.hpp" + + class test : public benchmark::test_case { diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 537feeead..740e75778 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ #include "csv_utils.hpp" +#include "csv_getline.hpp" #include "csv_datasource.hpp" #include "csv_featureset.hpp" #include "csv_inline_featureset.hpp" diff --git a/plugins/input/csv/csv_utils.hpp b/plugins/input/csv/csv_utils.hpp index b82077381..019de51d7 100644 --- a/plugins/input/csv/csv_utils.hpp +++ b/plugins/input/csv/csv_utils.hpp @@ -49,8 +49,7 @@ namespace csv_utils static const mapnik::csv_line_grammar line_g; static const mapnik::csv_white_space_skipper skipper; -template -static mapnik::csv_line parse_line(Iterator start, Iterator end, char separator, char quote, std::size_t num_columns) +static mapnik::csv_line parse_line(char const* start, char const* end, char separator, char quote, std::size_t num_columns) { mapnik::csv_line values; if (num_columns > 0) values.reserve(num_columns); @@ -87,43 +86,6 @@ inline bool ignore_case_equal(std::string const& s0, std::string const& s1) s1.begin(), ignore_case_equal_pred()); } -template -std::basic_istream& getline_csv(std::istream& is, std::basic_string& s, CharT delim, CharT quote) -{ - typename std::basic_string::size_type nread = 0; - typename std::basic_istream::sentry sentry(is, true); - if (sentry) - { - std::basic_streambuf* buf = is.rdbuf(); - s.clear(); - bool has_quote = false; - while (nread < s.max_size()) - { - int c1 = buf->sbumpc(); - if (Traits::eq_int_type(c1, Traits::eof())) - { - is.setstate(std::ios_base::eofbit); - break; - } - else - { - ++nread; - CharT c = Traits::to_char_type(c1); - if (Traits::eq(c, quote)) - has_quote = !has_quote; - if (!Traits::eq(c, delim) || has_quote) - s.push_back(c); - else - break;// Character is extracted but not appended. - } - } - } - if (nread == 0 || nread >= s.max_size()) - is.setstate(std::ios_base::failbit); - - return is; -} - } diff --git a/utils/mapnik-index/process_csv_file.cpp b/utils/mapnik-index/process_csv_file.cpp index bfe7d3064..fade7183e 100644 --- a/utils/mapnik-index/process_csv_file.cpp +++ b/utils/mapnik-index/process_csv_file.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ #include "process_csv_file.hpp" +#include "../../plugins/input/csv/csv_getline.hpp" #include "../../plugins/input/csv/csv_utils.hpp" #include #include