kraken: csv: expose 'read_csv_line'
This commit is contained in:
parent
6fc5502b99
commit
8474ed0c69
|
@ -4,10 +4,7 @@
|
||||||
|
|
||||||
namespace kraken::csv {
|
namespace kraken::csv {
|
||||||
|
|
||||||
namespace {
|
csv_line_type read_csv_line(std::string const& line) {
|
||||||
|
|
||||||
// for convenience, use a stringstream which does not accept string_view inputs
|
|
||||||
csv_line_type parse_line(std::string const& line) {
|
|
||||||
auto parsed = csv_line_type{};
|
auto parsed = csv_line_type{};
|
||||||
|
|
||||||
auto input = std::istringstream(line);
|
auto input = std::istringstream(line);
|
||||||
|
@ -18,8 +15,6 @@ csv_line_type parse_line(std::string const& line) {
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
csv_type read_csv(std::istream& input, CsvHeader header) {
|
csv_type read_csv(std::istream& input, CsvHeader header) {
|
||||||
auto parsed = std::vector<csv_line_type>{};
|
auto parsed = std::vector<csv_line_type>{};
|
||||||
|
|
||||||
|
@ -30,7 +25,7 @@ csv_type read_csv(std::istream& input, CsvHeader header) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
parsed.emplace_back(parse_line(std::move(line)));
|
parsed.emplace_back(read_csv_line(std::move(line)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
|
|
|
@ -14,6 +14,9 @@ enum class CsvHeader {
|
||||||
KEEP,
|
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.
|
/// 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);
|
csv_type read_csv(std::istream& input, CsvHeader header = CsvHeader::SKIP);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue