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;
50 CSV_INLINE void CSVFormat::assert_no_char_overlap()
52 auto delims = std::set<char>(
53 this->possible_delimiters.begin(), this->possible_delimiters.end()),
54 trims = std::set<char>(
55 this->trim_chars.begin(), this->trim_chars.end());
58 std::vector<char> intersection = {};
61 std::set_intersection(
62 delims.begin(), delims.end(),
63 trims.begin(), trims.end(),
64 std::back_inserter(intersection));
68 if (delims.find(this->quote_char) != delims.end() ||
69 trims.find(this->quote_char) != trims.end()) {
70 intersection.push_back(this->quote_char);
73 if (!intersection.empty()) {
74 std::string err_msg =
"There should be no overlap between the quote character, "
75 "the set of possible delimiters "
76 "and the set of whitespace characters. Offending characters: ";
80 for (
size_t i = 0; i < intersection.size(); i++) {
82 err_msg += intersection[i];
85 if (i + 1 < intersection.size())
89 throw std::runtime_error(err_msg +
'.');
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
The all encompassing namespace.