mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 19:22:17 +01:00
Fix constness of ArgsManager methods
This commit is contained in:
32
src/util.cpp
32
src/util.cpp
@@ -419,49 +419,48 @@ void ArgsManager::ParseParameters(int argc, const char* const argv[])
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg)
|
||||
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
if (IsArgSet(strArg))
|
||||
return mapMultiArgs.at(strArg);
|
||||
auto it = mapMultiArgs.find(strArg);
|
||||
if (it != mapMultiArgs.end()) return it->second;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ArgsManager::IsArgSet(const std::string& strArg)
|
||||
bool ArgsManager::IsArgSet(const std::string& strArg) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
return mapArgs.count(strArg);
|
||||
}
|
||||
|
||||
std::string ArgsManager::GetArg(const std::string& strArg, const std::string& strDefault)
|
||||
std::string ArgsManager::GetArg(const std::string& strArg, const std::string& strDefault) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
if (mapArgs.count(strArg))
|
||||
return mapArgs[strArg];
|
||||
auto it = mapArgs.find(strArg);
|
||||
if (it != mapArgs.end()) return it->second;
|
||||
return strDefault;
|
||||
}
|
||||
|
||||
int64_t ArgsManager::GetArg(const std::string& strArg, int64_t nDefault)
|
||||
int64_t ArgsManager::GetArg(const std::string& strArg, int64_t nDefault) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
if (mapArgs.count(strArg))
|
||||
return atoi64(mapArgs[strArg]);
|
||||
auto it = mapArgs.find(strArg);
|
||||
if (it != mapArgs.end()) return atoi64(it->second);
|
||||
return nDefault;
|
||||
}
|
||||
|
||||
bool ArgsManager::GetBoolArg(const std::string& strArg, bool fDefault)
|
||||
bool ArgsManager::GetBoolArg(const std::string& strArg, bool fDefault) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
if (mapArgs.count(strArg))
|
||||
return InterpretBool(mapArgs[strArg]);
|
||||
auto it = mapArgs.find(strArg);
|
||||
if (it != mapArgs.end()) return InterpretBool(it->second);
|
||||
return fDefault;
|
||||
}
|
||||
|
||||
bool ArgsManager::SoftSetArg(const std::string& strArg, const std::string& strValue)
|
||||
{
|
||||
LOCK(cs_args);
|
||||
if (mapArgs.count(strArg))
|
||||
return false;
|
||||
if (IsArgSet(strArg)) return false;
|
||||
ForceSetArg(strArg, strValue);
|
||||
return true;
|
||||
}
|
||||
@@ -478,8 +477,7 @@ void ArgsManager::ForceSetArg(const std::string& strArg, const std::string& strV
|
||||
{
|
||||
LOCK(cs_args);
|
||||
mapArgs[strArg] = strValue;
|
||||
mapMultiArgs[strArg].clear();
|
||||
mapMultiArgs[strArg].push_back(strValue);
|
||||
mapMultiArgs[strArg] = {strValue};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user