#include <writer.hpp>
Public Member Functions | |
| Writer (std::ostream &output, const anch::csv::Options &options=anch::csv::Options()) | |
| Writer (const Writer &)=delete | |
| void | write (std::span< const std::string_view > fields) |
| void | write (std::initializer_list< std::string_view > fields) |
| template<typename... V> | |
| void | writeRow (const V &... values) |
| void | write (std::span< const std::string_view > fields, const std::vector< bool > "ed) |
| const anch::csv::Options & | options () const noexcept |
CSV records writer (RFC 4180): fields which contain the separator, the quote, CR or LF are quoted (quotes are doubled), as a first field which begins with an UTF-8 BOM. Records end with CRLF (or LF , Options::crlf ). The header is written as a record ( Options::header is not used by the writer) ; an UTF-8 BOM is written by the constructor with Options::bom .
| anch::csv::Writer::Writer | ( | std::ostream & | output, |
| const anch::csv::Options & | options = anch::csv::Options() ) |
Writer constructor
| output | the output stream |
| options | the options |
| std::invalid_argument | when separator and quote are equal, or one of them is CR or LF |
|
delete |
|
noexcept |
Options getter
| void anch::csv::Writer::write | ( | std::initializer_list< std::string_view > | fields | ) |
Write a record
| fields | the fields |
| void anch::csv::Writer::write | ( | std::span< const std::string_view > | fields | ) |
Write a record
| fields | the fields |
| void anch::csv::Writer::write | ( | std::span< const std::string_view > | fields, |
| const std::vector< bool > & | quoted ) |
Write a record whose fields can be quoted even without special character: an empty quoted field ( "" ) is an empty string, an empty field an absent value
| fields | the fields |
| quoted | the fields to quote (same size as fields ) |
| void anch::csv::Writer::writeRow | ( | const V &... | values | ) |
Write a record of values: strings as is, bool as true / false , numbers with std::to_chars
| values | the values |