diff options
author | Evan Klitzke <evan@eklitzke.org> | 2018-03-21 19:24:17 -0700 |
---|---|---|
committer | Evan Klitzke <evan@eklitzke.org> | 2018-03-27 22:12:02 -0700 |
commit | f7683cba7b070b722a2e0641f4d1516112392ed6 (patch) | |
tree | 6352a758ef05dc2dc28de2f8f23fa94c656baeee /src/util.h | |
parent | 4f872b24501f40bd410227b5413bda2f2569af24 (diff) |
Track negated arguments in the argument paser.
This commit adds tracking for negated arguments. This change will be used in a
future commit that allows disabling the debug.log file using -nodebuglogfile.
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h index 592041c0cf..4c473c9354 100644 --- a/src/util.h +++ b/src/util.h @@ -25,6 +25,7 @@ #include <map> #include <stdint.h> #include <string> +#include <unordered_set> #include <vector> #include <boost/signals2/signal.hpp> @@ -224,6 +225,8 @@ protected: mutable CCriticalSection cs_args; std::map<std::string, std::string> mapArgs; std::map<std::string, std::vector<std::string>> mapMultiArgs; + std::unordered_set<std::string> m_negated_args; + public: void ParseParameters(int argc, const char*const argv[]); void ReadConfigFile(const std::string& confPath); @@ -245,6 +248,15 @@ public: bool IsArgSet(const std::string& strArg) const; /** + * Return true if the argument was originally passed as a negated option, + * i.e. -nofoo. + * + * @param strArg Argument to get (e.g. "-foo") + * @return true if the argument was passed negated + */ + bool IsArgNegated(const std::string& strArg) const; + + /** * Return string argument or default value * * @param strArg Argument to get (e.g. "-foo") @@ -292,6 +304,11 @@ public: // Forces an arg setting. Called by SoftSetArg() if the arg hasn't already // been set. Also called directly in testing. void ForceSetArg(const std::string& strArg, const std::string& strValue); + +private: + + // Munge -nofoo into -foo=0 and track the value as negated. + void InterpretNegatedOption(std::string &key, std::string &val); }; extern ArgsManager gArgs; |