Helpers to write dsf's delimiter-separated output files.
More...
#include <csv.hpp>
#include <format>
#include <fstream>
#include <ios>
#include <stdexcept>
#include <string>
|
| std::ofstream | dsf::utility::openCSVFile (std::string const &fileName, std::ios::openmode const mode=std::ios::app) |
| | Open a CSV file for writing.
|
Helpers to write dsf's delimiter-separated output files.
This file wraps the csv-parser writer with the conventions dsf uses for its CSV artifacts, so that every component writing one agrees on the separator and on how the output stream is opened.
- Note
- Internal header: it is excluded from the install because it exposes csv-parser, which dsf links as a build-only private dependency. Include it from dsf implementation files only, never from an installed header.
◆ CSVRowWriter
The writer used for dsf's CSV artifacts.
dsf CSV files are semicolon-separated. csv::DelimWriter takes the delimiter as a template parameter and only holds a reference to the output stream, so the caller owns the std::ofstream it is built on and must keep it alive for at least as long as the writer.
◆ openCSVFile()
| std::ofstream dsf::utility::openCSVFile |
( |
std::string const & | fileName, |
|
|
std::ios::openmode const | mode = std::ios::app ) |
|
inline |
Open a CSV file for writing.
- Parameters
-
| fileName | The path of the file to open |
| mode | The open mode. Defaults to appending, so that rows flushed over several calls accumulate in the same file |
- Returns
- std::ofstream The output stream, which must outlive any writer built on it
- Exceptions
-
| std::runtime_error | If the file cannot be opened |