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;
39 this->col_names_explicitly_set_ =
true;
44 if (row < 0) this->variable_column_policy = VariableColumnPolicy::KEEP;
47 this->header_explicitly_set_ =
true;
49 this->col_names_explicitly_set_ =
false;
54 if (size < internals::CSV_CHUNK_SIZE_FLOOR) {
55 throw std::invalid_argument(
56 "Chunk size must be at least " +
57 std::to_string(internals::CSV_CHUNK_SIZE_FLOOR) +
58 " bytes (500KB). Provided: " + std::to_string(size)
61 this->_chunk_size = size;
65 CSV_INLINE void CSVFormat::assert_no_char_overlap()
67 const std::set<char> delims(this->possible_delimiters.begin(), this->possible_delimiters.end());
68 const std::set<char> trims(this->trim_chars.begin(), this->trim_chars.end());
69 std::set<char> offenders;
71 for (std::set<char>::const_iterator it = delims.begin(); it != delims.end(); ++it) {
72 if (trims.find(*it) != trims.end()) {
73 offenders.insert(*it);
79 if (delims.find(this->quote_char) != delims.end() ||
80 trims.find(this->quote_char) != trims.end()) {
81 offenders.insert(this->quote_char);
84 if (!offenders.empty()) {
85 std::string err_msg =
"There should be no overlap between the quote character, "
86 "the set of possible delimiters "
87 "and the set of whitespace characters. Offending characters: ";
92 for (std::set<char>::const_iterator it = offenders.begin(); it != offenders.end(); ++it, ++i) {
97 if (i + 1 < offenders.size())
101 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.