diff --git a/src/eckit/option/FactoryOption.cc b/src/eckit/option/FactoryOption.cc index 8276eeee6..893bc3525 100644 --- a/src/eckit/option/FactoryOption.cc +++ b/src/eckit/option/FactoryOption.cc @@ -16,15 +16,11 @@ #include -#include "eckit/config/Configuration.h" #include "eckit/config/Configured.h" - #include "eckit/exception/Exceptions.h" #include "eckit/option/FactoryOption.h" -#include "eckit/utils/Translator.h" -namespace eckit { -namespace option { +namespace eckit::option { template @@ -62,11 +58,9 @@ void FactoryOption::copy(const Configuration& from, Configured& to) const { template void FactoryOption::print(std::ostream& out) const { - out << " --" << name_ << "=name" - << " (" << description_ << ")"; + out << " --" << name_ << "=name" << " (" << description_ << ")"; out << std::endl << " Values are: "; T::list(out); } -} // namespace option -} // namespace eckit +} // namespace eckit::option diff --git a/src/eckit/option/FactoryOption.h b/src/eckit/option/FactoryOption.h index 073a24351..025849003 100644 --- a/src/eckit/option/FactoryOption.h +++ b/src/eckit/option/FactoryOption.h @@ -12,9 +12,7 @@ /// @author Tiago Quintino /// @date Apr 2015 - -#ifndef eckit_option_FactoryOption_H -#define eckit_option_FactoryOption_H +#pragma once #include @@ -52,5 +50,3 @@ class FactoryOption : public BaseOption { } // namespace eckit::option #include "eckit/option/FactoryOption.cc" - -#endif diff --git a/src/eckit/option/MultiValueOption.cc b/src/eckit/option/MultiValueOption.cc index 5b1cd8212..fef4ee220 100644 --- a/src/eckit/option/MultiValueOption.cc +++ b/src/eckit/option/MultiValueOption.cc @@ -13,9 +13,7 @@ #include #include -#include "eckit/config/Configuration.h" #include "eckit/config/Configured.h" - #include "eckit/exception/Exceptions.h" namespace eckit::option { @@ -39,16 +37,15 @@ MultiValueOption::MultiValueOption(const std::string& name, const std::string& d size_t n_optional_values, std::optional default_values) : base_t(name, description, std::move(default_values)), n_mandatory_values_{n_mandatory_values}, - n_optional_values_{n_optional_values}, - values_{} { + n_optional_values_{n_optional_values} { ASSERT_MSG(n_mandatory_values >= 1, "At least 1 mandatory value is expected."); } size_t MultiValueOption::set(Configured& parametrisation, [[maybe_unused]] size_t values, args_t::const_iterator begin, args_t::const_iterator end) const { if (std::distance(begin, end) < n_mandatory_values_) { - throw UserError("Not enough option values found for MultiValueOption, where at least " + - std::to_string(n_mandatory_values_) + " were expected"); + throw UserError("Not enough option values found for MultiValueOption, where at least " + + std::to_string(n_mandatory_values_) + " were expected"); } // Collect n_mandatory_values_ mandatory values from the range [begin, end) diff --git a/src/eckit/option/MultiValueOption.h b/src/eckit/option/MultiValueOption.h index fd4108360..9d6998e16 100644 --- a/src/eckit/option/MultiValueOption.h +++ b/src/eckit/option/MultiValueOption.h @@ -8,8 +8,7 @@ * does it submit to any jurisdiction. */ -#ifndef eckit_option_MultiValueOption_H -#define eckit_option_MultiValueOption_H +#pragma once #include @@ -23,9 +22,12 @@ class MultiValueOption : public BaseOption> { using values_t = std::vector; MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values); - MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, size_t n_optional_values); - MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, const values_t& default_values); - MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, size_t n_optional_values, const values_t& default_values); + MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, + size_t n_optional_values); + MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, + const values_t& default_values); + MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, + size_t n_optional_values, const values_t& default_values); ~MultiValueOption() override = default; size_t set(Configured&, size_t values, args_t::const_iterator begin, args_t::const_iterator end) const override; @@ -33,7 +35,8 @@ class MultiValueOption : public BaseOption> { void print(std::ostream&) const override; private: - MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, size_t n_maximum_values, std::optional default_values); + MultiValueOption(const std::string& name, const std::string& description, size_t n_mandatory_values, + size_t n_maximum_values, std::optional default_values); void set_value(const values_t& values, Configured&) const override; @@ -47,5 +50,3 @@ class MultiValueOption : public BaseOption> { }; } // namespace eckit::option - -#endif diff --git a/src/eckit/option/SimpleOption.cc b/src/eckit/option/SimpleOption.cc index ea1bb4de3..a816643f8 100644 --- a/src/eckit/option/SimpleOption.cc +++ b/src/eckit/option/SimpleOption.cc @@ -18,7 +18,6 @@ #include "eckit/config/Configuration.h" #include "eckit/config/Configured.h" - #include "eckit/exception/Exceptions.h" #include "eckit/filesystem/PathName.h" #include "eckit/option/SimpleOption.h" @@ -68,12 +67,12 @@ void SimpleOption::set_value(const T& value, Configured& parametrisation) con template T SimpleOption::translate(const std::string& value) const { - T v = eckit::Translator()(value); + T v = Translator()(value); return v; } template <> -inline void SimpleOption::copy(const Configuration& from, Configured& to) const { +inline void SimpleOption::copy(const Configuration& from, Configured& to) const { std::string v; if (from.get(name_, v)) { to.set(name_, v); diff --git a/src/eckit/option/SimpleOption.h b/src/eckit/option/SimpleOption.h index 168401529..6bd3c8a20 100644 --- a/src/eckit/option/SimpleOption.h +++ b/src/eckit/option/SimpleOption.h @@ -12,9 +12,7 @@ /// @author Tiago Quintino /// @date Apr 2015 - -#ifndef eckit_option_SimpleOption_H -#define eckit_option_SimpleOption_H +#pragma once #include @@ -39,7 +37,6 @@ class SimpleOption : public BaseOption { void print(std::ostream&) const override; private: - void set_value(const T& value, Configured&) const override; [[nodiscard]] T translate(const std::string& value) const override; @@ -50,5 +47,3 @@ class SimpleOption : public BaseOption { } // namespace eckit::option #include "eckit/option/SimpleOption.cc" - -#endif diff --git a/src/eckit/option/VectorOption.cc b/src/eckit/option/VectorOption.cc index 3f612568d..66ba5efbc 100644 --- a/src/eckit/option/VectorOption.cc +++ b/src/eckit/option/VectorOption.cc @@ -23,13 +23,7 @@ #include "eckit/utils/Tokenizer.h" #include "eckit/utils/Translator.h" - -namespace eckit { - -namespace option { - -//---------------------------------------------------------------------------------------------------------------------- - +namespace eckit::option { template VectorOption::VectorOption(const std::string& name, const std::string& description, size_t size, @@ -61,9 +55,9 @@ void VectorOption::set_value(const std::vector& value, Configured& paramet template std::vector VectorOption::translate(const std::string& value) const { - eckit::Translator t; + Translator t; - eckit::Tokenizer parse(separator_); + Tokenizer parse(separator_); std::vector tokens; parse(value, tokens); @@ -97,16 +91,9 @@ void VectorOption::print(std::ostream& out) const { out << " (" << this->description() << ")"; } - template void VectorOption::copy(const Configuration& from, Configured& to) const { Option::copy>(this->name(), from, to); } - -//---------------------------------------------------------------------------------------------------------------------- - - -} // namespace option - -} // namespace eckit +} // namespace eckit::option diff --git a/src/eckit/option/VectorOption.h b/src/eckit/option/VectorOption.h index 5a49817dc..84b6a57a9 100644 --- a/src/eckit/option/VectorOption.h +++ b/src/eckit/option/VectorOption.h @@ -13,8 +13,7 @@ /// @date Apr 2015 -#ifndef VectorOption_H -#define VectorOption_H +#pragma once #include @@ -33,7 +32,8 @@ class VectorOption : public BaseOption> { // -- Contructors VectorOption(const std::string& name, const std::string& description, size_t size, const char* separator = "/"); - VectorOption(const std::string& name, const std::string& description, size_t size, const std::vector& default_value, const char* separator = "/"); + VectorOption(const std::string& name, const std::string& description, size_t size, + const std::vector& default_value, const char* separator = "/"); // -- Destructor @@ -106,5 +106,3 @@ class VectorOption : public BaseOption> { } // namespace eckit::option #include "eckit/option/VectorOption.cc" - -#endif