diff --git a/src/csv/CMakeLists.txt b/src/csv/CMakeLists.txt index 38e27b5..3821532 100644 --- a/src/csv/CMakeLists.txt +++ b/src/csv/CMakeLists.txt @@ -2,5 +2,7 @@ add_library(csv STATIC csv.hh read-csv.cc read-csv.hh + write-csv.cc + write-csv.hh ) target_link_libraries(csv PRIVATE common_options) diff --git a/src/csv/write-csv.cc b/src/csv/write-csv.cc new file mode 100644 index 0000000..186947c --- /dev/null +++ b/src/csv/write-csv.cc @@ -0,0 +1,16 @@ +#include "write-csv.hh" + +#include +#include +#include + +namespace kraken::csv { + +void write_csv(std::ostream& output, csv_type const& csv) { + for (const auto& line : csv) { + std::ranges::copy(line, + std::ostream_iterator{output, ","}); + } +} + +} // namespace kraken::csv diff --git a/src/csv/write-csv.hh b/src/csv/write-csv.hh new file mode 100644 index 0000000..d3dd402 --- /dev/null +++ b/src/csv/write-csv.hh @@ -0,0 +1,14 @@ +#pragma once + +#include +#include +#include + +#include "csv/csv.hh" + +namespace kraken::csv { + +/// Write raw CSV data to an output-stream. +void write_csv(std::ostream& output, csv_type const& csv); + +} // namespace kraken::csv