From 8474ed0c69f46133076ccca524d6a3cbd7942cce Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 24 Mar 2022 17:17:09 +0100 Subject: [PATCH] kraken: csv: expose 'read_csv_line' --- src/csv/read-csv.cc | 9 ++------- src/csv/read-csv.hh | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/csv/read-csv.cc b/src/csv/read-csv.cc index 5274d12..002922b 100644 --- a/src/csv/read-csv.cc +++ b/src/csv/read-csv.cc @@ -4,10 +4,7 @@ namespace kraken::csv { -namespace { - -// for convenience, use a stringstream which does not accept string_view inputs -csv_line_type parse_line(std::string const& line) { +csv_line_type read_csv_line(std::string const& line) { auto parsed = csv_line_type{}; auto input = std::istringstream(line); @@ -18,8 +15,6 @@ csv_line_type parse_line(std::string const& line) { return parsed; } -} // namespace - csv_type read_csv(std::istream& input, CsvHeader header) { auto parsed = std::vector{}; @@ -30,7 +25,7 @@ csv_type read_csv(std::istream& input, CsvHeader header) { continue; } - parsed.emplace_back(parse_line(std::move(line))); + parsed.emplace_back(read_csv_line(std::move(line))); } return parsed; diff --git a/src/csv/read-csv.hh b/src/csv/read-csv.hh index 674da6a..6e0542a 100644 --- a/src/csv/read-csv.hh +++ b/src/csv/read-csv.hh @@ -14,6 +14,9 @@ enum class CsvHeader { KEEP, }; +/// Parse a single CSV line, no error checking. +csv_line_type read_csv_line(std::string const& input); + /// Parse a CSV file from an input-stream, return a vector of parsed lines. csv_type read_csv(std::istream& input, CsvHeader header = CsvHeader::SKIP);