|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_FORMATS_CSV_READER_H_
2 #define GENESIS_UTILS_FORMATS_CSV_READER_H_
79 using Line = std::vector<Field>;
80 using Table = std::vector<Line>;
106 Table read( std::shared_ptr<BaseInputSource> source )
const;
171 comment_chars_ = chars;
183 return comment_chars_;
229 quotation_chars_ = chars;
241 return quotation_chars_;
261 separator_chars_ = chars;
273 return separator_chars_;
286 skip_empty_lines_ = value;
297 return skip_empty_lines_;
320 merge_separators_ = value;
331 return merge_separators_;
348 use_escapes_ = value;
384 use_twin_quotes_ = value;
395 return use_twin_quotes_;
408 std::string comment_chars_ =
"";
409 std::string trim_chars_ =
"";
410 std::string quotation_chars_ =
"\"";
411 std::string separator_chars_ =
",";
413 bool skip_empty_lines_ =
false;
414 bool merge_separators_ =
false;
415 bool use_escapes_ =
false;
416 bool use_twin_quotes_ =
true;
422 mutable std::string buffer_;
429 #endif // include guard
std::vector< std::string > parse_line(utils::InputStream &input_stream) const
Parse one line of the CSV data and return it.
CsvReader & trim_chars(std::string const &chars)
Set chars that are trimmed from the start and end of each field.
CsvReader & separator_chars(std::string const &chars)
Set the chars used to separate fields of the CSV data.
std::string const & separator_chars() const
Return the currently set chars used to separate fields of the CSV data.
bool skip_empty_lines() const
Return whether currently empty lines are skipped.
bool merge_separators() const
Return the current setting whether consecutive separators are merged or not.
CsvReader & skip_empty_lines(bool value)
Set whether to skip empty lines.
CsvReader & use_twin_quotes(bool value)
Set whether to interpret two consequtive quotation marks as a single ("escaped") one.
Table parse_document(utils::InputStream &input_stream) const
Parse a whole CSV document and return its contents.
CsvReader & operator=(CsvReader const &)=default
CsvReader & comment_chars(std::string const &chars)
Set chars that are used to mark comment lines.
CsvReader & use_escapes(bool value)
Set whether to use backslash escape sequences.
CsvReader & quotation_chars(std::string const &chars)
Set the chars that are used for quoting strings in fields.
Table read(std::shared_ptr< BaseInputSource > source) const
Read CSV data from a source and return it as a table, using a vector per line, containing a vector of...
CsvReader & merge_separators(bool value)
Set whether consecutive separater chars are merged or whether each of them creates a new field.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::string const & comment_chars() const
Return the currently set chars that are used to mark comment lines.
std::string parse_field(utils::InputStream &input_stream) const
Parse one field (i.e., one cell) of the CSV data and return it.
std::vector< Field > Line
std::vector< Line > Table
std::string const & quotation_chars() const
Return the currently set chars for quoting strings in fields.
std::string const & trim_chars() const
Return the currently set chars that are trimmed from the start and end of each field.
bool use_escapes() const
Return whether backslash escape sequences are used.
Read Comma/Character Separated Values (CSV) data and other delimiter-separated formats.
bool use_twin_quotes() const
Return whether to interpret two consequtive quotation marks as a single ("escaped") one.