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