aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-07-27 10:19:53 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-07-27 15:05:14 +0300
commit265c1b58d89b7b6fb30468ba402d7f75cc59a510 (patch)
treeaf29b6ddde03bfc975825c67d6f42f990a90c940
parente0d187dfeb18b026de22bd7960b2a50c2b958e1a (diff)
downloadbitcoin-265c1b58d89b7b6fb30468ba402d7f75cc59a510.tar.xz
Add Flags enum to ArgsManager
-rw-r--r--src/util/system.cpp2
-rw-r--r--src/util/system.h20
2 files changed, 19 insertions, 3 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index eb3f90dcf7..155809c220 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -549,7 +549,7 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
LOCK(cs_args);
std::map<std::string, Arg>& arg_map = m_available_args[cat];
- auto ret = arg_map.emplace(name.substr(0, eq_index), Arg(name.substr(eq_index, name.size() - eq_index), help, debug_only));
+ auto ret = arg_map.emplace(name.substr(0, eq_index), Arg{name.substr(eq_index, name.size() - eq_index), help, ArgsManager::NONE, debug_only});
assert(ret.second); // Make sure an insertion actually happened
}
diff --git a/src/util/system.h b/src/util/system.h
index 66a9eb4612..27b364a5e2 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -127,6 +127,23 @@ struct SectionInfo
class ArgsManager
{
+public:
+ enum Flags {
+ NONE = 0x00,
+ // Boolean options can accept negation syntax -noOPTION or -noOPTION=1
+ ALLOW_BOOL = 0x01,
+ ALLOW_INT = 0x02,
+ ALLOW_STRING = 0x04,
+ ALLOW_ANY = ALLOW_BOOL | ALLOW_INT | ALLOW_STRING,
+ DEBUG_ONLY = 0x100,
+ /* Some options would cause cross-contamination if values for
+ * mainnet were used while running on regtest/testnet (or vice-versa).
+ * Setting them as NETWORK_ONLY ensures that sharing a config file
+ * between mainnet and regtest/testnet won't cause problems due to these
+ * parameters by accident. */
+ NETWORK_ONLY = 0x200,
+ };
+
protected:
friend class ArgsManagerHelper;
@@ -134,9 +151,8 @@ protected:
{
std::string m_help_param;
std::string m_help_text;
+ unsigned int m_flags;
bool m_debug_only;
-
- Arg(const std::string& help_param, const std::string& help_text, bool debug_only) : m_help_param(help_param), m_help_text(help_text), m_debug_only(debug_only) {};
};
mutable CCriticalSection cs_args;