1#ifndef CSV_FILE_WRITER_H
2#define CSV_FILE_WRITER_H
7#include <initializer_list>
55 template <
typename T>
void write_row(
const std::vector<T> &
vals);
70 template <
typename...
T>
void write_row(
const std::tuple<T...> &
row);
94 throw std::logic_error(
"File " + this->
file_name_ +
" is not open");
103 if (
c ==
vals.size() - 1)
119 throw std::logic_error(
"File " + this->
file_name_ +
" is not open");
144 throw std::logic_error(
"File " + this->
file_name_ +
" is not open");
150 f <<
vals[
c] << std::endl;
158 std::apply([&](
auto &&...
args) { ((
f <<
args <<
","), ...); },
row);
The CSVWriter class. Handles writing into CSV file format.
Definition csv_file_writer.h:22
void write_column_names(const std::vector< std::string > &col_names, bool write_header=true)
Write the column names.
Definition csv_file_writer.cpp:16
char get_delimiter() const noexcept
Returns the column delimiter.
Definition csv_file_writer.h:80
void write_row(const std::vector< T > &vals)
Write a row of the file.
Definition csv_file_writer.h:89
void write_column_vector(const std::vector< T > &vals)
Write the given vector as a column.
Definition csv_file_writer.h:139
static char default_delimiter()
The default column delimiter.
Definition csv_file_writer.h:28
void set_delimiter(char delim) noexcept
Set the delimiter.
Definition csv_file_writer.h:75
handler_type & get_file_stream() noexcept
Returns the underlying file stream.
Definition file_handler_base.h:39
std::string file_name_
The name of the file to write.
Definition file_handler_base.h:81
bool is_open() const noexcept
Return true if and only if the file is open.
Definition file_handler_base.h:55
The FileWriterBase class.
Definition file_writer_base.h:20
virtual void write_header()
Write the header of the file. By default some information such as date and time the file was created ...
Definition file_writer_base.cpp:59
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
Eigen::RowVectorX< T > DynVec
Dynamically sized row vector.
Definition bitrl_types.h:74
std::size_t uint_t
uint_t
Definition bitrl_types.h:43