16 template<
typename RowSink,
typename ParsePolicy,
typename FieldPolicy,
typename RowPolicy>
19 class CSVParserDriverBase;
109 this->no_quote = !use_quote;
115 this->variable_column_policy = policy;
132 this->_column_name_policy = policy;
157 this->_threading = enabled;
166 this->_speculative_parallel_threads = n_threads;
172 this->_speculative_parallel_min_bytes = bytes;
182 this->_eager_field_classification = enabled;
186#ifndef DOXYGEN_SHOULD_SKIP_THIS
187 char get_delim()
const {
189 if (this->possible_delimiters.size() > 1) {
190 throw std::runtime_error(internals::ERROR_MULTIPLE_DELIMITERS);
193 return this->possible_delimiters.at(0);
196 CONSTEXPR bool is_quoting_enabled()
const {
return !this->no_quote; }
197 CONSTEXPR char get_quote_char()
const {
return this->quote_char; }
198 CONSTEXPR int get_header()
const {
return this->header; }
199 std::vector<char> get_possible_delims()
const {
return this->possible_delimiters; }
200 std::vector<char> get_trim_chars()
const {
return this->trim_chars; }
201 const std::vector<std::string>&
get_col_names()
const {
return this->col_names; }
204 CONSTEXPR size_t get_chunk_size()
const {
return this->_chunk_size; }
205 CONSTEXPR bool is_threading_enabled()
const {
206#if CSV_ENABLE_THREADS
207 return this->_threading;
212 CONSTEXPR size_t get_speculative_parallel_threads()
const {
return this->_speculative_parallel_threads; }
213 CONSTEXPR size_t get_speculative_parallel_min_bytes()
const {
return this->_speculative_parallel_min_bytes; }
214 CONSTEXPR bool is_eager_field_classification_enabled()
const {
return this->_eager_field_classification; }
215 CONSTEXPR bool should_use_speculative_parallel(
size_t source_size,
size_t n_threads)
const {
216#if CSV_ENABLE_THREADS
217 return this->_threading
219 && source_size >= this->_speculative_parallel_min_bytes;
231 format.
delimiter({
',',
'|',
'\t',
';',
'^' })
241 bool guess_delim()
const {
242 return this->possible_delimiters.size() > 1;
246 template<
typename RowSink,
typename ParsePolicy,
typename FieldPolicy,
typename RowPolicy>
247 friend class internals::CSVParserCore;
248 friend internals::parser::CSVParserDriverBase;
252 void assert_no_char_overlap();
255 std::vector<char> possible_delimiters = {
',' };
258 std::vector<char> trim_chars = {};
264 bool header_explicitly_set_ =
false;
267 bool no_quote =
false;
270 char quote_char =
'"';
273 std::vector<std::string> col_names = {};
276 bool col_names_explicitly_set_ =
false;
285 size_t _chunk_size = internals::CSV_CHUNK_SIZE_DEFAULT;
288 bool _threading =
true;
291 size_t _speculative_parallel_threads = 0;
294 size_t _speculative_parallel_min_bytes = internals::CSV_SPECULATIVE_PARALLEL_MIN_BYTES;
297 bool _eager_field_classification =
false;
Main class for parsing CSVs from files and in-memory sources.
A standalone header file containing shared code.
#define CONSTEXPR
Expands to constexpr in decent compilers and inline otherwise.
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
Shared exception message templates and throw helpers.
The all encompassing namespace.
ColumnNamePolicy
Determines how column name lookups are performed.
@ CASE_INSENSITIVE
Case-insensitive match.
@ EXACT
Case-sensitive match (default)
VariableColumnPolicy
Determines how to handle rows that are shorter or longer than the majority.
std::vector< std::string > get_col_names(csv::string_view filename, const CSVFormat &format=CSVFormat::guess_csv())
Get the column names of a CSV file using just the first 500KB.
Stores the inferred format of a CSV file.