kraken: csv: add writing functionality
Once again, pretty naive, but it will do.
This commit is contained in:
parent
0dee0e12dc
commit
23b71018ac
|
@ -2,5 +2,7 @@ add_library(csv STATIC
|
||||||
csv.hh
|
csv.hh
|
||||||
read-csv.cc
|
read-csv.cc
|
||||||
read-csv.hh
|
read-csv.hh
|
||||||
|
write-csv.cc
|
||||||
|
write-csv.hh
|
||||||
)
|
)
|
||||||
target_link_libraries(csv PRIVATE common_options)
|
target_link_libraries(csv PRIVATE common_options)
|
||||||
|
|
16
src/csv/write-csv.cc
Normal file
16
src/csv/write-csv.cc
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "write-csv.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
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<std::string>{output, ","});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace kraken::csv
|
14
src/csv/write-csv.hh
Normal file
14
src/csv/write-csv.hh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#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
|
Loading…
Reference in a new issue