Vince's CSV Parser
csv::CSVFormat Class Reference

Stores information about how to parse a CSV file. More...

#include <csv_format.hpp>

Public Member Functions

 CSVFormat ()=default
 Settings for parsing a RFC 4180 CSV file.
 
CSVFormatdelimiter (char delim)
 Sets the delimiter of the CSV file. More...
 
CSVFormatdelimiter (const std::vector< char > &delim)
 Sets a list of potential delimiters. More...
 
CSVFormattrim (const std::vector< char > &ws)
 Sets the whitespace characters to be trimmed. More...
 
CSVFormatquote (char quote)
 Sets the quote character. More...
 
CSVFormatcolumn_names (const std::vector< std::string > &names)
 Sets the column names. More...
 
CSVFormatheader_row (int row)
 Sets the header row. More...
 
CSVFormatno_header ()
 Tells the parser that this CSV has no header row. More...
 
CSVFormatquote (bool use_quote)
 Turn quoting on or off.
 
CONSTEXPR_14 CSVFormatvariable_columns (VariableColumnPolicy policy=VariableColumnPolicy::IGNORE_ROW)
 Tells the parser how to handle columns of a different length than the others.
 
CONSTEXPR_14 CSVFormatvariable_columns (bool policy)
 Tells the parser how to handle columns of a different length than the others.
 
bool guess_delim ()
 

Static Public Member Functions

static CSVFormat guess_csv ()
 CSVFormat for guessing the delimiter.
 

Public Attributes

friend CSVReader
 

Detailed Description

Stores information about how to parse a CSV file.

Can be used to construct a csv::CSVReader.

Definition at line 36 of file csv_format.hpp.

Member Function Documentation

◆ column_names()

CSVFormat & csv::CSVFormat::column_names ( const std::vector< std::string > &  names)

Sets the column names.

Note
Unsets any values set by header_row()

Definition at line 36 of file csv_format.cpp.

◆ delimiter() [1/2]

CSVFormat & csv::CSVFormat::delimiter ( char  delim)

Sets the delimiter of the CSV file.

Exceptions
<tt>std::runtime_error</tt>thrown if trim, quote, or possible delimiting characters overlap

Definition at line 11 of file csv_format.cpp.

◆ delimiter() [2/2]

CSVFormat & csv::CSVFormat::delimiter ( const std::vector< char > &  delim)

Sets a list of potential delimiters.

Exceptions
<tt>std::runtime_error</tt>thrown if trim, quote, or possible delimiting characters overlap
Parameters
[in]delimAn array of possible delimiters to try parsing the CSV with

Definition at line 17 of file csv_format.cpp.

◆ header_row()

CSVFormat & csv::CSVFormat::header_row ( int  row)

Sets the header row.

Note
Unsets any values set by column_names()

Definition at line 42 of file csv_format.cpp.

◆ no_header()

CSVFormat& csv::CSVFormat::no_header ( )
inline

Tells the parser that this CSV has no header row.

Note
Equivalent to header_row(-1)

Definition at line 84 of file csv_format.hpp.

◆ quote()

CSVFormat & csv::CSVFormat::quote ( char  quote)

Sets the quote character.

Exceptions
<tt>std::runtime_error</tt>thrown if trim, quote, or possible delimiting characters overlap

Definition at line 23 of file csv_format.cpp.

◆ trim()

CSVFormat & csv::CSVFormat::trim ( const std::vector< char > &  ws)

Sets the whitespace characters to be trimmed.

Exceptions
<tt>std::runtime_error</tt>thrown if trim, quote, or possible delimiting characters overlap
Parameters
[in]wsAn array of whitespace characters that should be trimmed

Definition at line 30 of file csv_format.cpp.


The documentation for this class was generated from the following files: