30#include <wreport/var.h>
68 std::vector<std::string>
cols;
78 void open(
const std::string& pathname);
121 static std::string unescape(
const std::string& csvstr);
void close()
Sets in to 0.
wreport::Varcode as_varcode(unsigned col) const
Return the given column, as a Varcode.
bool next()
Read the next CSV line, returning false if EOF is reached.
bool close_on_exit
If true, the input stream will be deleted upon destruction.
Definition: csv.h:63
bool move_to_data(unsigned number_col=0)
Find the first line where the given column exists and starts with a number.
std::string line
Last line read.
Definition: csv.h:65
std::vector< std::string > cols
Parsed CSV columns for the last line read.
Definition: csv.h:68
void open(const std::string &pathname)
Open the given file and sets close_on_exit to true.
int as_int_withmissing(unsigned col) const
Return the given column, as an integer.
int as_int(unsigned col) const
Return the given column, as an integer.
virtual void flush_row()=0
Write the current line to the output file, and start a new one.
void add_value(const std::string &val)
Add a string to the current row.
void add_var_value_raw(const wreport::Var &val)
Add a variable value, in its raw integer form.
void add_value(unsigned val)
Add an int value to the current row.
void add_value(const char *val)
Add a string to the current row.
void add_var_value_formatted(const wreport::Var &val)
Add a variable value, formatted.
void add_value_raw(const char *str)
Add a value to the current row, without any escaping.
void add_value_withmissing(int val)
Add an int value that can potentially be missing.
void add_value(uint64_t val)
Add an int value to the current row.
void add_value_raw(const std::string &str)
Add a value to the current row, without any escaping.
void add_value(wreport::Varcode val)
Add a formatted varcode to the current row.
void add_value(int val)
Add an int value to the current row.
void add_value_empty()
Add an empty value to the current row.
bool csv_read_next(FILE *in, std::vector< std::string > &cols)
Parse a CSV line.
void csv_output_quoted_string(std::ostream &out, const std::string &str)
Output a string value, quoted if needed according to CSV rules.