# HG changeset patch # User František Kučera # Date 1600853193 -7200 # Node ID 157bb1d5e08a01004fffe12ca599f8c16d7fba98 # Parent 012d491e219a53837293dd14fb240926ef837dee work with writer instead of ostream diff -r 012d491e219a -r 157bb1d5e08a src/CSVCommand.cpp --- a/src/CSVCommand.cpp Wed Sep 23 11:23:12 2020 +0200 +++ b/src/CSVCommand.cpp Wed Sep 23 11:26:33 2020 +0200 @@ -87,9 +87,8 @@ return false; } -void CSVCommand::processDataStream(std::ostream& output, std::istream& input, const vector& args) { +void CSVCommand::process(std::istream& input, const vector& args, std::shared_ptr writer) { wstring_convert < codecvt_utf8> convertor; // UTF-8 is required for CSV - std::shared_ptr writer(Factory::create(output)); vector metadata; bool headerDone = false; bool lastInRecord = false; diff -r 012d491e219a -r 157bb1d5e08a src/CSVCommand.h --- a/src/CSVCommand.h Wed Sep 23 11:23:12 2020 +0200 +++ b/src/CSVCommand.h Wed Sep 23 11:26:33 2020 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -30,7 +31,7 @@ private: bool readValue(std::istream& input, std::stringstream& currentValue, bool& lastInRecord); public: - void processDataStream(std::ostream &output, std::istream& input, const vector& args); + void process(std::istream& input, const vector& args, std::shared_ptr writer); }; diff -r 012d491e219a -r 157bb1d5e08a src/relpipe-in-csv.cpp --- a/src/relpipe-in-csv.cpp Wed Sep 23 11:23:12 2020 +0200 +++ b/src/relpipe-in-csv.cpp Wed Sep 23 11:26:33 2020 +0200 @@ -45,7 +45,8 @@ try { CSVCommand command; - command.processDataStream(cout, cin, cli.arguments()); + std::shared_ptr writer(Factory::create(std::cout)); + command.process(cin, cli.arguments(), writer); resultCode = CLI::EXIT_CODE_SUCCESS; } catch (RelpipeWriterException e) { fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str());