When you don't know the header names in advance, you cannot use this great library. This PR introduces a helper that allows to use a workaround for setting column names after the header was read.
How is this PR trying to accomplish said thing?
I added an internal array of column names that gets filled when we read the header. After this we can use a trick to reuse this column names for actual reading using set_header_from_self().
How is this PR tested?
Manually and as part of a test suite in a different project.
Additional context
Illustration of how it is used:
io::CSVReader<COLUMNS_COUNT,
io::trim_chars<' ', '\t'>,
io::double_quote_escape<',', '\"'>,
io::ignore_overflow,
io::single_and_empty_line_comment<'%'>> csvReader(filepath);
// CsvCallHelper is just a C++ templates expander, it does not matter for this PR
CsvCallHelper<decltype(csvReader)> callHelper(csvReader);
std::vector<std::string> fakeColumns(COLUMNS_COUNT);
csvReader.next_line();
callHelper.ReadHeader<io::ignore_column, COLUMNS_COUNT>(io::ignore_missing_column | io::ignore_extra_column, fakeColumns);
csvReader.set_header_from_self();
std::vector<std::string> columns(COLUMNS_COUNT);
while (callHelper.ReadRow<COLUMNS_COUNT>(columns)) {
// ...
}
What is this PR trying to accomplish?
When you don't know the header names in advance, you cannot use this great library. This PR introduces a helper that allows to use a workaround for setting column names after the header was read.
How is this PR trying to accomplish said thing?
I added an internal array of column names that gets filled when we read the header. After this we can use a trick to reuse this column names for actual reading using
set_header_from_self()
.How is this PR tested?
Manually and as part of a test suite in a different project.
Additional context
Illustration of how it is used: