diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-03-17 22:56:47 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-03-17 22:56:47 +0100 |
commit | 7edc4328bfd5eee557108ebdb4243ca06914c41e (patch) | |
tree | fd01761ed57c6f5d31409c7777b4c0c127a1e482 /apps/sample-convert.cpp | |
parent | 5d6e4c971857b5e05d7c277e7eafcb9d64dbc6a7 (diff) | |
download | ble-toys-7edc4328bfd5eee557108ebdb4243ca06914c41e.tar.gz ble-toys-7edc4328bfd5eee557108ebdb4243ca06914c41e.tar.bz2 ble-toys-7edc4328bfd5eee557108ebdb4243ca06914c41e.tar.xz ble-toys-7edc4328bfd5eee557108ebdb4243ca06914c41e.zip |
o cout and unique_ptr became complicated.
o Updating lots of code to the latest api.
Diffstat (limited to 'apps/sample-convert.cpp')
-rw-r--r-- | apps/sample-convert.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/sample-convert.cpp b/apps/sample-convert.cpp index 5e87a15..c5e9c4f 100644 --- a/apps/sample-convert.cpp +++ b/apps/sample-convert.cpp @@ -49,11 +49,11 @@ public: } } - unique_ptr<ostream> outputStream; + shared_ptr<ostream> outputStream; if (output_file == "-") { - outputStream = unique_ptr<ostream>(&cout); + outputStream = shared_ptr<ostream>(&cout, noop_deleter); } else { - outputStream = make_unique<ofstream>(output_file); + outputStream = make_shared<ofstream>(output_file); if (outputStream->fail()) { cerr << "Unable to open output file " << output_file << endl; return EXIT_FAILURE; @@ -61,16 +61,18 @@ public: } if (output_format == "plain") { - output = make_shared<CsvSampleOutputStream>(move(outputStream), dict); + output = make_shared<CsvSampleOutputStream>(outputStream, dict); } else if (output_format == "json") { - output = make_shared<JsonSampleOutputStream>(move(outputStream), dict); + output = make_shared<JsonSampleOutputStream>(outputStream, dict); } else if (output_format == "sql") { if (table_name.size() == 0) { cerr << "Missing option: table-name" << endl; return EXIT_FAILURE; } - output = make_shared<SqlSampleOutputStream>(move(outputStream), dict, table_name); + output = make_shared<SqlSampleOutputStream>(outputStream, dict, table_name); + } else if (output_format == "csv") { + output = make_shared<CsvSampleOutputStream>(outputStream, dict); } else { cerr << "Unsupported output format: " << output_format << endl; return EXIT_FAILURE; |