mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Merge #13733: Utils: Refactor ArgsManager a little
9544a3f3fc
tiny refactor for ArgsManager (AtsukiTak)
Pull request description:
This PR contains some small refactors for `ArgsManager`.
1. Mark `const` on member function if it possible.
2. Remove unused `error` argument from `ArgsManager::IsArgKnown`.
I'm not sure whether these refactors should be separated into another PR. If so, I will do that.
Tree-SHA512: 7df09e7f7c4cdd2e7cd60e34137faa7ca7463be66490f8552fdea3656da6ccc98886e258bdeef21820d197fc2fde06ab2d3405205f5de53f258df7c191d206b0
This commit is contained in:
commit
0d1ebf4d3f
2 changed files with 6 additions and 6 deletions
|
@ -446,7 +446,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||||
|
|
||||||
// Check that the arg is known
|
// Check that the arg is known
|
||||||
if (!(IsSwitchChar(key[0]) && key.size() == 1)) {
|
if (!(IsSwitchChar(key[0]) && key.size() == 1)) {
|
||||||
if (!IsArgKnown(key, error)) {
|
if (!IsArgKnown(key)) {
|
||||||
error = strprintf("Invalid parameter %s", key.c_str());
|
error = strprintf("Invalid parameter %s", key.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArgsManager::IsArgKnown(const std::string& key, std::string& error)
|
bool ArgsManager::IsArgKnown(const std::string& key) const
|
||||||
{
|
{
|
||||||
size_t option_index = key.find('.');
|
size_t option_index = key.find('.');
|
||||||
std::string arg_no_net;
|
std::string arg_no_net;
|
||||||
|
@ -591,7 +591,7 @@ void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ArgsManager::GetHelpMessage()
|
std::string ArgsManager::GetHelpMessage() const
|
||||||
{
|
{
|
||||||
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);
|
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);
|
||||||
|
|
||||||
|
@ -859,7 +859,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, std::string& error, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the arg is known
|
// Check that the arg is known
|
||||||
if (!IsArgKnown(strKey, error) && !ignore_invalid_keys) {
|
if (!IsArgKnown(strKey) && !ignore_invalid_keys) {
|
||||||
error = strprintf("Invalid configuration value %s", option.first.c_str());
|
error = strprintf("Invalid configuration value %s", option.first.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,12 +276,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the help string
|
* Get the help string
|
||||||
*/
|
*/
|
||||||
std::string GetHelpMessage();
|
std::string GetHelpMessage() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether we know of this arg
|
* Check whether we know of this arg
|
||||||
*/
|
*/
|
||||||
bool IsArgKnown(const std::string& key, std::string& error);
|
bool IsArgKnown(const std::string& key) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ArgsManager gArgs;
|
extern ArgsManager gArgs;
|
||||||
|
|
Loading…
Add table
Reference in a new issue