From 1fb2bc651c910e241f1b36bd4cabc3f762b35e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 14 Apr 2015 13:39:43 +0200 Subject: [PATCH] Store unhandled command-line arguments. A new method ParameterGroup::unhandledArguments() is available to access the list of unhandled arguments. Before, when such arguments were encountered they were ignored and a warning was printed to standard out. Apart from the lack of a (potentially misleading) warning, this should not change the behaviour of existing clients of the class. --- opm/core/utility/parameters/ParameterGroup.cpp | 5 +++++ opm/core/utility/parameters/ParameterGroup.hpp | 4 ++++ opm/core/utility/parameters/ParameterGroup_impl.hpp | 4 +--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup.cpp b/opm/core/utility/parameters/ParameterGroup.cpp index a6d7837d..21f642df 100644 --- a/opm/core/utility/parameters/ParameterGroup.cpp +++ b/opm/core/utility/parameters/ParameterGroup.cpp @@ -329,5 +329,10 @@ namespace Opm { } } + const std::vector ParameterGroup::unhandledArguments() const + { + return unhandled_arguments_; + } + } // namespace parameter } // namespace Opm diff --git a/opm/core/utility/parameters/ParameterGroup.hpp b/opm/core/utility/parameters/ParameterGroup.hpp index 466d242c..a4368805 100644 --- a/opm/core/utility/parameters/ParameterGroup.hpp +++ b/opm/core/utility/parameters/ParameterGroup.hpp @@ -267,6 +267,9 @@ namespace Opm { /// Insert a new parameter item into the group. void insertParameter(const std::string& name, const std::string& value); + /// Unhandled arguments from command line parsing. + const std::vector unhandledArguments() const; + private: typedef std::shared_ptr data_type; typedef std::pair pair_type; @@ -276,6 +279,7 @@ namespace Opm { map_type map_; const ParameterGroup* parent_; bool output_is_enabled_; + std::vector unhandled_arguments_; template T translate(const pair_type& data, const Requirement& chk) const; diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index eb8ebb1b..96deee4a 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -150,9 +150,7 @@ namespace Opm { } else if (file_type.second == "param") { this->readParam(files[i]); } else { - std::cout << "WARNING: Ignoring file '" - << files[i] << "' with unknown extension.\n" - << "Valid filename extensions are 'xml' and 'param'.\n"; + unhandled_arguments_.push_back(files[i]); } } for (int i = 0; i < int(assignments.size()); ++i) {