From 17de795175d0573d8ac6c2517d0eb35e8a4f8f69 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 18 Mar 2015 23:02:25 +0100 Subject: o Replacing custom Format with common sample_format_type. --- apps/sample-convert.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'apps/sample-convert.cpp') diff --git a/apps/sample-convert.cpp b/apps/sample-convert.cpp index 79d6f1c..c6f5d01 100644 --- a/apps/sample-convert.cpp +++ b/apps/sample-convert.cpp @@ -18,9 +18,9 @@ public: options ("help", "produce this help message") ("input", po::value(&input_file)->default_value("-")) - ("input-format", po::value(&input_format)->default_value("csv")) +// ("input-format", po::value(&input_format)->default_value("csv")) ("output", po::value(&output_file)->default_value("-")) - ("output-format", po::value(&output_format)->default_value("plain")); + ("output-format", po::value(&output_format)->default_value(sample_format_type::KEY_VALUE)); } void add_extra_options(po::options_description &all_options) override { @@ -36,7 +36,6 @@ public: auto vm = execution.vm; KeyDictionary dict; - shared_ptr output; istream *inputStream; if (input_file == "-") { @@ -60,23 +59,7 @@ public: } } - if (output_format == "plain") { - output = make_shared(outputStream, dict); - } else if (output_format == "json") { - output = make_shared(outputStream, dict); - } else if (output_format == "sql") { - if (table_name.size() == 0) { - cerr << "Missing option: table-name" << endl; - return EXIT_FAILURE; - } - - output = make_shared(outputStream, dict, table_name); - } else if (output_format == "csv") { - output = make_shared(outputStream, dict); - } else { - cerr << "Unsupported output format: " << output_format << endl; - return EXIT_FAILURE; - } + shared_ptr output = open_sample_output_stream(outputStream, dict, output_format); auto input = make_shared(output, dict); @@ -90,8 +73,8 @@ public: } private: - string input_file, input_format; - string output_file, output_format; + string input_file, output_file; + sample_format_type output_format; string table_name; }; -- cgit v1.2.3