kraken: csv: move type aliases to 'csv.hh' header

As we need to share it with the CSV writing files.
This commit is contained in:
Bruno BELANYI 2022-03-12 00:12:03 +01:00
parent 697f941cb2
commit 0dee0e12dc
3 changed files with 17 additions and 8 deletions

View file

@ -1,4 +1,5 @@
add_library(csv STATIC add_library(csv STATIC
csv.hh
read-csv.cc read-csv.cc
read-csv.hh read-csv.hh
) )

14
src/csv/csv.hh Normal file
View file

@ -0,0 +1,14 @@
#pragma once
#include <string>
#include <vector>
namespace kraken::csv {
/// Represent a raw CSV line as a vector of strings.
using csv_line_type = std::vector<std::string>;
/// Represent a raw CSV file as a vector of raw CSV lines
using csv_type = std::vector<csv_line_type>;
} // namespace kraken::csv

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <iosfwd> #include <iosfwd>
#include <string>
#include <vector> #include "csv/csv.hh"
namespace kraken::csv { namespace kraken::csv {
@ -14,12 +14,6 @@ enum class CsvHeader {
KEEP, KEEP,
}; };
/// Represent a raw CSV line as a vector of strings.
using csv_line_type = std::vector<std::string>;
/// Represent a raw CSV file as a vector of raw CSV lines
using csv_type = std::vector<csv_line_type>;
/// 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);