19 template<
typename RowSink,
typename ParsePolicy,
typename FieldPolicy,
typename RowPolicy>
22 class CSVParserDriverBase;
65#if CSV_EXCEPTIONS_ENABLED
75#if CSV_EXCEPTIONS_ENABLED
83#if CSV_EXCEPTIONS_ENABLED
91#if CSV_EXCEPTIONS_ENABLED
101 bool try_trim(
const std::vector<char>& whitespace,
CSVError& error);
135 this->no_quote = !use_quote;
141 this->variable_column_policy = policy;
158 this->_column_name_policy = policy;
171#if CSV_EXCEPTIONS_ENABLED
185 this->_threading = enabled;
194 this->_speculative_parallel_threads = n_threads;
200 this->_speculative_parallel_min_bytes = bytes;
210 this->_eager_field_classification = enabled;
214#ifndef DOXYGEN_SHOULD_SKIP_THIS
215#if CSV_EXCEPTIONS_ENABLED
216 char get_delim()
const;
219 CONSTEXPR bool is_quoting_enabled()
const {
return !this->no_quote; }
220 CONSTEXPR char get_quote_char()
const {
return this->quote_char; }
221 CONSTEXPR int get_header()
const {
return this->header; }
222 std::vector<char> get_possible_delims()
const {
return this->possible_delimiters; }
223 std::vector<char> get_trim_chars()
const {
return this->trim_chars; }
224 const std::vector<std::string>&
get_col_names()
const {
return this->col_names; }
227 CONSTEXPR size_t get_chunk_size()
const {
return this->_chunk_size; }
228 CONSTEXPR bool is_threading_enabled()
const {
229#if CSV_ENABLE_THREADS
230 return this->_threading;
235 CONSTEXPR size_t get_speculative_parallel_threads()
const {
return this->_speculative_parallel_threads; }
236 CONSTEXPR size_t get_speculative_parallel_min_bytes()
const {
return this->_speculative_parallel_min_bytes; }
237 CONSTEXPR bool is_eager_field_classification_enabled()
const {
return this->_eager_field_classification; }
238 CONSTEXPR bool should_use_speculative_parallel(
size_t source_size,
size_t n_threads)
const {
239#if CSV_ENABLE_THREADS
240 return this->_threading
242 && source_size >= this->_speculative_parallel_min_bytes;
254 bool guess_delim()
const {
255 return this->possible_delimiters.size() > 1;
259 template<
typename RowSink,
typename ParsePolicy,
typename FieldPolicy,
typename RowPolicy>
260 friend class internals::CSVParserCore;
261 friend internals::parser::CSVParserDriverBase;
262 friend char internals::resolved_delimiter(
const CSVFormat& format)
noexcept;
265 static bool validate_characters(
266 const std::vector<char>& delims,
const std::vector<char>& whitespace,
267 char quote, CSVError& error);
270 std::vector<char> possible_delimiters = {
',' };
273 std::vector<char> trim_chars = {};
279 bool header_explicitly_set_ =
false;
282 bool no_quote =
false;
285 char quote_char =
'"';
288 std::vector<std::string> col_names = {};
291 bool col_names_explicitly_set_ =
false;
300 size_t _chunk_size = internals::CSV_CHUNK_SIZE_DEFAULT;
303 bool _threading =
true;
306 size_t _speculative_parallel_threads = 0;
309 size_t _speculative_parallel_min_bytes = internals::CSV_SPECULATIVE_PARALLEL_MIN_BYTES;
312 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.
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.
A diagnostic whose text remains valid for the lifetime of the error.
Stores the inferred format of a CSV file.