Utility
Utility code for I/O.
Header: fiction/io/csv_writer.hpp
-
class csv_writer
Utility class for writing delimited (e.g. CSV) data into an output stream. It provides a variadic member function,
write_line
, that can take an arbitrary number of arguments and write them to the provided output stream in a line separated by a specified delimiter.The csv_writer follows some behavior principles:
Any standard data type can be written to the output stream.
Data arguments written will be separated by the specified delimiter.
A newline is written at the end of each line.
If
write_line
receives no arguments, it only writes a newline.The last value written in a line is not followed by a delimiter.
No checks for escape characters are performed.
Example usage:
std::ofstream file("output.csv"); csv_writer writer(file); writer.write_line("Name", "Age", "City"); writer.write_line("Alice", 20, "New York");