Fix issue #659, and cleanup wallet/command-line argument handling a bit

This commit is contained in:
Gavin Andresen
2012-01-03 10:14:22 -05:00
parent 4231eb217c
commit 0fcf91ea1e
5 changed files with 84 additions and 43 deletions

View File

@@ -439,7 +439,7 @@ inline int64 GetArg(const std::string& strArg, int64 nDefault)
return nDefault;
}
inline bool GetBoolArg(const std::string& strArg)
inline bool GetBoolArg(const std::string& strArg, bool fDefault=false)
{
if (mapArgs.count(strArg))
{
@@ -447,9 +447,26 @@ inline bool GetBoolArg(const std::string& strArg)
return true;
return (atoi(mapArgs[strArg]) != 0);
}
return false;
return fDefault;
}
/**
* Set an argument if it doesn't already have a value
*
* @param strArg Argument to set (e.g. "-foo")
* @param strValue Value (e.g. "1")
* @return true if argument gets set, false if it already had a value
*/
bool SoftSetArg(const std::string& strArg, const std::string& strValue);
/**
* Set a boolean argument if it doesn't already have a value
*
* @param strArg Argument to set (e.g. "-foo")
* @param fValue Value (e.g. false)
* @return true if argument gets set, false if it already had a value
*/
bool SoftSetArg(const std::string& strArg, bool fValue);