12 this->possible_delimiters = { delim };
13 this->assert_no_char_overlap();
18 this->possible_delimiters = delim;
19 this->assert_no_char_overlap();
24 this->no_quote =
false;
25 this->quote_char =
quote;
26 this->assert_no_char_overlap();
31 this->trim_chars = chars;
32 this->assert_no_char_overlap();
37 this->col_names = names;
43 if (row < 0) this->variable_column_policy = VariableColumnPolicy::KEEP;
52 throw std::invalid_argument(
53 "Chunk size must be at least " +
55 " bytes (10MB). Provided: " + std::to_string(size)
58 this->_chunk_size = size;
62 CSV_INLINE void CSVFormat::assert_no_char_overlap()
64 auto delims = std::set<char>(
65 this->possible_delimiters.begin(), this->possible_delimiters.end()),
66 trims = std::set<char>(
67 this->trim_chars.begin(), this->trim_chars.end());
70 std::vector<char> intersection = {};
73 std::set_intersection(
74 delims.begin(), delims.end(),
75 trims.begin(), trims.end(),
76 std::back_inserter(intersection));
80 if (delims.find(this->quote_char) != delims.end() ||
81 trims.find(this->quote_char) != trims.end()) {
82 intersection.push_back(this->quote_char);
85 if (!intersection.empty()) {
86 std::string err_msg =
"There should be no overlap between the quote character, "
87 "the set of possible delimiters "
88 "and the set of whitespace characters. Offending characters: ";
92 for (
size_t i = 0; i < intersection.size(); i++) {
94 err_msg += intersection[i];
97 if (i + 1 < intersection.size())
101 throw std::runtime_error(err_msg +
'.');
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
constexpr size_t ITERATION_CHUNK_SIZE
Chunk size for lazy-loading large CSV files.
The all encompassing namespace.