From d781938ec3beb5f8158333c0e46b6b1bb88156c5 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 7 Apr 2017 20:23:42 +0200 Subject: Add override to memfilepersistence. --- .../src/vespa/vespalib/util/programoptions.h | 81 +++++++++------------- 1 file changed, 31 insertions(+), 50 deletions(-) (limited to 'staging_vespalib/src') diff --git a/staging_vespalib/src/vespa/vespalib/util/programoptions.h b/staging_vespalib/src/vespa/vespalib/util/programoptions.h index 58d1d133d04..9e25f960af7 100644 --- a/staging_vespalib/src/vespa/vespalib/util/programoptions.h +++ b/staging_vespalib/src/vespa/vespalib/util/programoptions.h @@ -23,12 +23,10 @@ #pragma once +#include #include #include -#include #include -#include -#include namespace vespalib { @@ -237,9 +235,9 @@ struct ProgramOptions::OptionParser { struct ProgramOptions::OptionHeader : public OptionParser { OptionHeader(const std::string& desc) : OptionParser("", 0, desc) {} - virtual void set(const std::vector&) override {} - virtual void setDefault() override {} - virtual bool isHeader() const override { return true; } + void set(const std::vector&) override {} + void setDefault() override {} + bool isHeader() const override { return true; } }; template @@ -262,61 +260,45 @@ struct ProgramOptions::NumberOptionParser : public OptionParser { : OptionParser(nameList, 1, getStringValue(defValue), desc), _number(number), _defaultValue(defValue) - { - } - - virtual void set(const std::vector& arguments) override; - - virtual void setDefault() override { _number = _defaultValue; } - - virtual std::string getArgType(uint32_t /* index */) const override - { return getTypeName(); } + {} + void set(const std::vector& arguments) override; + void setDefault() override { _number = _defaultValue; } + std::string getArgType(uint32_t /* index */) const override { + return getTypeName(); + } }; struct ProgramOptions::BoolOptionParser : public OptionParser { bool& _value; bool _defaultValue; - BoolOptionParser(const std::string& nameList, bool& value, - const std::string& description); - - virtual void set(const std::vector&) override { _value = true; } - - virtual void setDefault() override { _value = false; } + BoolOptionParser(const std::string& nameList, bool& value, const std::string& description); + void set(const std::vector&) override { _value = true; } + void setDefault() override { _value = false; } }; struct ProgramOptions::FlagOptionParser : public OptionParser { bool& _value; bool _unsetValue; - FlagOptionParser(const std::string& nameList, bool& value, - const std::string& description); - FlagOptionParser(const std::string& nameList, bool& value, - const bool& unsetValue, const std::string& description); - - virtual void set(const std::vector&) override { _value = !_unsetValue; } - - virtual void setDefault() override { _value = _unsetValue; } + FlagOptionParser(const std::string& nameList, bool& value, const std::string& description); + FlagOptionParser(const std::string& nameList, bool& value, const bool& unsetValue, const std::string& description); + void set(const std::vector&) override { _value = !_unsetValue; } + void setDefault() override { _value = _unsetValue; } }; struct ProgramOptions::StringOptionParser : public OptionParser { std::string& _value; std::string _defaultValue; - StringOptionParser(const std::string& nameList, std::string& value, - const std::string& description); - + StringOptionParser(const std::string& nameList, std::string& value, const std::string& description); StringOptionParser(const std::string& nameList, std::string& value, const std::string& defVal, const std::string& desc); - virtual void set(const std::vector& arguments) override - { _value = arguments[0]; } - - virtual void setDefault() override { _value = _defaultValue; } - - virtual std::string getArgType(uint32_t /* index */) const override - { return "string"; } + void set(const std::vector& arguments) override { _value = arguments[0]; } + void setDefault() override { _value = _defaultValue; } + std::string getArgType(uint32_t /* index */) const override { return "string"; } }; struct ProgramOptions::MapOptionParser : public OptionParser { @@ -327,14 +309,14 @@ struct ProgramOptions::MapOptionParser : public OptionParser { std::map& value, const std::string& description); - virtual void set(const std::vector& arguments) override - { _value[arguments[0]] = arguments[1]; } + void set(const std::vector& arguments) override { + _value[arguments[0]] = arguments[1]; + } - virtual std::string getArgType(uint32_t /* index */) const override - { return "string"; } + std::string getArgType(uint32_t /* index */) const override { return "string"; } - // Default of map is just an empty map. - virtual void setDefault() override { _value.clear(); } + // Default of map is just an empty map. + void setDefault() override { _value.clear(); } }; template @@ -356,9 +338,8 @@ struct ProgramOptions::ListOptionParser : public OptionParser { void setEntryParser(OptionParser::UP entryParser) { _entryParser = std::move(entryParser); } - - virtual bool isRequired() const override { return false; } - virtual void set(const std::vector& arguments) override { + bool isRequired() const override { return false; } + void set(const std::vector& arguments) override { for (uint32_t i=0; i v; v.push_back(arguments[i]); @@ -366,10 +347,10 @@ struct ProgramOptions::ListOptionParser : public OptionParser { _value.push_back(_singleValue); } } - virtual void setDefault() override { + void setDefault() override { _value.clear(); } - virtual std::string getArgType(uint32_t index) const override { + std::string getArgType(uint32_t index) const override { return _entryParser->getArgType(index) + "[]"; } }; -- cgit v1.2.3