|
Vince's CSV Parser
|
Class for writing delimiter separated values files. More...
#include <csv_writer.hpp>
Public Member Functions | |
| DelimWriter (OutputStream &_out, bool _quote_minimal=true) | |
| Construct a DelimWriter over the specified output stream. | |
| template<typename T = OutputStream, csv::enable_if_t< std::is_same< T, std::ofstream >::value, int > = 0> | |
| DelimWriter (const std::string &filename, bool _quote_minimal=true) | |
| Construct a DelimWriter that owns an output file stream. | |
| DelimWriter (const DelimWriter &)=delete | |
| DelimWriter & | operator= (const DelimWriter &)=delete |
| DelimWriter (DelimWriter &&other) noexcept | |
| DelimWriter & | operator= (DelimWriter &&other) noexcept |
| DelimWriter & | set_auto_flush (bool value) &noexcept |
| Configure whether each write operation flushes the underlying stream. | |
| DelimWriter && | set_auto_flush (bool value) &&noexcept |
| Configure whether each write operation flushes the underlying stream. | |
| bool | get_auto_flush () const noexcept |
| Return whether each write operation flushes the underlying stream. | |
| ~DelimWriter () | |
| Destructor will flush remaining data. | |
| template<typename T , size_t N> | |
| DelimWriter & | operator<< (const T(&record)[N]) |
| Write a C-style array of strings as one delimited row. | |
| template<typename T , size_t N> | |
| DelimWriter & | operator<< (const std::array< T, N > &record) |
| Write a std::array of strings as one delimited row. | |
| template<typename T > | |
| auto | write_row (T &&record) -> decltype(*this<< std::forward< T >(record)) |
| Write a row from any single argument accepted by operator<< (std::vector, std::array, std::tuple, C-array, C++20 range, etc.). | |
| template<typename T , typename U , typename... Rest> | |
| DelimWriter & | write_row (T &&first, U &&second, Rest &&... rest) |
| Write a row from a variadic list of mixed-type values. | |
| template<std::ranges::input_range Rows> requires internals::csv_write_rows_input_range<Rows> | |
| DelimWriter & | write_rows (Rows &&rows) |
| Write many rows using a shared batch buffer. | |
| template<std::ranges::input_range Range> requires std::ranges::input_range<Range> && std::convertible_to<std::ranges::range_reference_t<Range>, csv::string_view> | |
| DelimWriter & | operator<< (Range &&container) |
| Write a range of string-like fields as one delimited row. | |
| template<typename RowLike > requires internals::has_to_sv_range<RowLike> && (!internals::csv_string_field_range<RowLike>) | |
| DelimWriter & | operator<< (const RowLike &row) |
| Write a row-like object that exposes to_sv_range(). | |
| template<typename... T> | |
| DelimWriter & | operator<< (const std::tuple< T... > &record) |
| Write a C-style array of strings as one delimited row. | |
| void | flush () |
| Flushes the written data. | |
Class for writing delimiter separated values files.
To write formatted strings, one should
| OutputStream | The output stream, e.g. std::ofstream, std::stringstream |
| Delim | The delimiter character |
| Quote | The quote character |
Definition at line 255 of file csv_writer.hpp.
|
inline |
Construct a DelimWriter over the specified output stream.
Definition at line 259 of file csv_writer.hpp.
|
inline |
Construct a DelimWriter that owns an output file stream.
Definition at line 265 of file csv_writer.hpp.
|
inlinenoexcept |
Definition at line 276 of file csv_writer.hpp.
|
inline |
Destructor will flush remaining data.
Definition at line 325 of file csv_writer.hpp.
|
inline |
Flushes the written data.
Definition at line 456 of file csv_writer.hpp.
|
inlinenoexcept |
Return whether each write operation flushes the underlying stream.
Definition at line 320 of file csv_writer.hpp.
|
inline |
Write a row-like object that exposes to_sv_range().
Definition at line 419 of file csv_writer.hpp.
|
inline |
Write a std::array of strings as one delimited row.
Definition at line 341 of file csv_writer.hpp.
|
inline |
Write a C-style array of strings as one delimited row.
Definition at line 450 of file csv_writer.hpp.
|
inline |
Write a C-style array of strings as one delimited row.
Definition at line 334 of file csv_writer.hpp.
|
inline |
Write a range of string-like fields as one delimited row.
Accepts any input_range whose elements are convertible to csv::string_view. This includes std::vector<std::string>, std::vector<csv::string_view>, std::array, C++20 views, etc.
Definition at line 410 of file csv_writer.hpp.
|
inlinenoexcept |
Definition at line 289 of file csv_writer.hpp.
|
inlinenoexcept |
Configure whether each write operation flushes the underlying stream.
Definition at line 314 of file csv_writer.hpp.
|
inlinenoexcept |
Configure whether each write operation flushes the underlying stream.
Definition at line 308 of file csv_writer.hpp.
|
inline |
Write a row from a variadic list of mixed-type values.
Requires at least two arguments; for a single container or tuple, use the single-argument overload above.
Definition at line 372 of file csv_writer.hpp.
|
inline |
Write a row from any single argument accepted by operator<< (std::vector, std::array, std::tuple, C-array, C++20 range, etc.).
SFINAE ensures this overload is only viable when the argument type is accepted by an existing operator<< overload.
Definition at line 358 of file csv_writer.hpp.
|
inline |
Write many rows using a shared batch buffer.
Accepts any input_range whose elements are either:
Buffered writers flush the batch when it grows large or when this call ends. Auto-flushing writers additionally flush the underlying stream once at the end of the bulk call.
Definition at line 393 of file csv_writer.hpp.