[osmium-tool] 36/44: Refactoring: Add output options in common function.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to tag v1.1.0
in repository osmium-tool.
commit a78b8c6a5a60be0c10020f09639615f2cde2bde3
Author: Jochen Topf <jochen at topf.org>
Date: Fri Jul 3 14:20:53 2015 +0200
Refactoring: Add output options in common function.
---
src/command_apply_changes.cpp | 6 ++----
src/command_cat.cpp | 7 ++-----
src/command_getid.cpp | 6 ++----
src/command_merge_changes.cpp | 6 ++----
src/command_renumber.cpp | 7 ++-----
src/command_time_filter.cpp | 6 ++----
src/osmc.hpp | 28 +++++++++++++++++++---------
7 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/src/command_apply_changes.cpp b/src/command_apply_changes.cpp
index 300416a..aaa2b9a 100644
--- a/src/command_apply_changes.cpp
+++ b/src/command_apply_changes.cpp
@@ -37,15 +37,13 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input file")
("simplify,s", "Simplify change")
("remove-deleted,r", "Remove deleted objects from output")
- ("generator", po::value<std::string>(), "Generator setting for file header")
- ("overwrite,O", "Allow existing output file to be overwritten")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filename", po::value<std::string>(), "OSM input file")
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index ec3f69c..25cf60e 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -36,15 +36,12 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input files")
- ("generator", po::value<std::string>(), "Generator setting for file header")
- ("output-header", po::value<std::vector<std::string>>(), "Add output header")
- ("overwrite,O", "Allow existing output file to be overwritten")
("object-type,t", po::value<std::vector<std::string>>(), "Read only objects of given type (node, way, relation, changeset)")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filenames", po::value<std::vector<std::string>>(), "Input files")
diff --git a/src/command_getid.cpp b/src/command_getid.cpp
index a1d91e4..a0bac2c 100644
--- a/src/command_getid.cpp
+++ b/src/command_getid.cpp
@@ -50,13 +50,11 @@ bool CommandGetId::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input file")
- ("generator", po::value<std::string>(), "Generator setting for file header")
- ("overwrite,O", "Allow existing output file to be overwritten")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filename", po::value<std::string>(), "OSM input file")
diff --git a/src/command_merge_changes.cpp b/src/command_merge_changes.cpp
index b9b6185..33870e6 100644
--- a/src/command_merge_changes.cpp
+++ b/src/command_merge_changes.cpp
@@ -38,14 +38,12 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input files")
("simplify,s", "Simplify change")
- ("generator", po::value<std::string>(), "Generator setting for file header")
- ("overwrite,O", "Allow existing output file to be overwritten")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filenames", po::value<std::vector<std::string>>(), "Input files")
diff --git a/src/command_renumber.cpp b/src/command_renumber.cpp
index 43eb79e..b893f64 100644
--- a/src/command_renumber.cpp
+++ b/src/command_renumber.cpp
@@ -46,15 +46,12 @@ bool CommandRenumber::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input files")
- ("generator", po::value<std::string>(), "Generator setting for file header")
("index-directory,i", po::value<std::string>(), "Index directory")
- ("output-header", po::value<std::vector<std::string>>(), "Add output header")
- ("overwrite,O", "Allow existing output file to be overwritten")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filename", po::value<std::string>(), "Input file")
diff --git a/src/command_time_filter.cpp b/src/command_time_filter.cpp
index 167271a..392ee44 100644
--- a/src/command_time_filter.cpp
+++ b/src/command_time_filter.cpp
@@ -36,13 +36,11 @@ bool CommandTimeFilter::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("verbose,v", "Set verbose mode")
- ("output,o", po::value<std::string>(), "Output file")
- ("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input file")
- ("generator", po::value<std::string>(), "Generator setting for file header")
- ("overwrite,O", "Allow existing output file to be overwritten")
;
+ add_output_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filename", po::value<std::string>(), "OSM input file")
diff --git a/src/osmc.hpp b/src/osmc.hpp
index 1b13027..a841363 100644
--- a/src/osmc.hpp
+++ b/src/osmc.hpp
@@ -171,7 +171,11 @@ protected:
public:
- void setup_output_file(const boost::program_options::variables_map& vm) {
+ void setup_output_file(const po::variables_map& vm) {
+ if (vm.count("generator")) {
+ m_generator = vm["generator"].as<std::string>();
+ }
+
if (vm.count("output")) {
m_output_filename = vm["output"].as<std::string>();
}
@@ -180,6 +184,10 @@ public:
m_output_format = vm["output-format"].as<std::string>();
}
+ if (vm.count("output-header")) {
+ m_output_headers = vm["output-header"].as<std::vector<std::string>>();
+ }
+
if (vm.count("overwrite")) {
m_output_overwrite = osmium::io::overwrite::allow;
}
@@ -188,17 +196,19 @@ public:
throw argument_error("When writing to STDOUT you need to use the --output-format,f option to declare the file format.");
}
- if (vm.count("generator")) {
- m_generator = vm["generator"].as<std::string>();
- }
-
- if (vm.count("output-header")) {
- m_output_headers = vm["output-header"].as<std::vector<std::string>>();
- }
-
m_output_file = osmium::io::File(m_output_filename, m_output_format);
}
+ void add_output_options(po::options_description& options) {
+ options.add_options()
+ ("generator", po::value<std::string>(), "Generator setting for file header")
+ ("output,o", po::value<std::string>(), "Output file")
+ ("output-format,f", po::value<std::string>(), "Format of output file")
+ ("output-header", po::value<std::vector<std::string>>(), "Add output header")
+ ("overwrite,O", "Allow existing output file to be overwritten")
+ ;
+ }
+
}; // class with_osm_output
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmium-tool.git
More information about the Pkg-grass-devel
mailing list