aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.h
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2021-10-24 02:26:19 -0400
committerCarl Dong <contact@carldong.me>2022-06-22 18:18:52 -0400
commitfc02f77ca604f0221171bfde3059b34f5d0fb1cd (patch)
treee1afcf97d71a2e0508803874f3490cab7e13de14 /src/util/system.h
parent57a491bee17af88f75c2cea8c109d93b1cdbc9a8 (diff)
downloadbitcoin-fc02f77ca604f0221171bfde3059b34f5d0fb1cd.tar.xz
ArgsMan: Add Get*Arg functions returning optional
This allows the caller to not provide a default at all and just check inside the optional to see if the arg was set or not.
Diffstat (limited to 'src/util/system.h')
-rw-r--r--src/util/system.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/system.h b/src/util/system.h
index 07d7a533aa..04c66341d3 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -161,8 +161,13 @@ struct SectionInfo
};
std::string SettingToString(const util::SettingsValue&, const std::string&);
+std::optional<std::string> SettingToString(const util::SettingsValue&);
+
int64_t SettingToInt(const util::SettingsValue&, int64_t);
+std::optional<int64_t> SettingToInt(const util::SettingsValue&);
+
bool SettingToBool(const util::SettingsValue&, bool);
+std::optional<bool> SettingToBool(const util::SettingsValue&);
class ArgsManager
{
@@ -335,6 +340,7 @@ protected:
* @return command-line argument or default value
*/
std::string GetArg(const std::string& strArg, const std::string& strDefault) const;
+ std::optional<std::string> GetArg(const std::string& strArg) const;
/**
* Return path argument or default value
@@ -356,6 +362,7 @@ protected:
* @return command-line argument (0 if invalid number) or default value
*/
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
+ std::optional<int64_t> GetIntArg(const std::string& strArg) const;
/**
* Return boolean argument or default value
@@ -365,6 +372,7 @@ protected:
* @return command-line argument or default value
*/
bool GetBoolArg(const std::string& strArg, bool fDefault) const;
+ std::optional<bool> GetBoolArg(const std::string& strArg) const;
/**
* Set an argument if it doesn't already have a value