![]() |
Bitcoin Core 30.99.0
P2P Digital Currency
|
#include <common/args.h>#include <chainparamsbase.h>#include <common/settings.h>#include <logging.h>#include <sync.h>#include <tinyformat.h>#include <univalue.h>#include <util/chaintype.h>#include <util/check.h>#include <util/fs.h>#include <util/fs_helpers.h>#include <util/strencodings.h>#include <util/string.h>#include <algorithm>#include <cassert>#include <cstdint>#include <cstdlib>#include <cstring>#include <map>#include <optional>#include <stdexcept>#include <string>#include <utility>#include <variant>Go to the source code of this file.
Macros | |
| #define | INSTANTIATE_INT_TYPE(Type) |
Functions | |
| static bool | InterpretBool (const std::string &strValue) |
| Interpret a string argument as a boolean. More... | |
| static std::string | SettingName (const std::string &arg) |
| KeyInfo | InterpretKey (std::string key) |
| Parse "name", "section.name", "noname", "section.noname" settings keys. More... | |
| std::optional< common::SettingsValue > | InterpretValue (const KeyInfo &key, const std::string *value, unsigned int flags, std::string &error) |
| Interpret settings value based on registered flags. More... | |
| static void | SaveErrors (const std::vector< std::string > errors, std::vector< std::string > *error_out) |
| std::optional< std::string > | SettingToString (const common::SettingsValue &value) |
| std::string | SettingToString (const common::SettingsValue &value, const std::string &strDefault) |
| template<std::integral Int> | |
| std::optional< Int > | SettingTo (const common::SettingsValue &value) |
| template<std::integral Int> | |
| Int | SettingTo (const common::SettingsValue &value, Int nDefault) |
| std::optional< bool > | SettingToBool (const common::SettingsValue &value) |
| bool | SettingToBool (const common::SettingsValue &value, bool fDefault) |
| INSTANTIATE_INT_TYPE (int8_t) | |
| INSTANTIATE_INT_TYPE (uint8_t) | |
| INSTANTIATE_INT_TYPE (int16_t) | |
| INSTANTIATE_INT_TYPE (uint16_t) | |
| INSTANTIATE_INT_TYPE (int32_t) | |
| INSTANTIATE_INT_TYPE (uint32_t) | |
| INSTANTIATE_INT_TYPE (int64_t) | |
| INSTANTIATE_INT_TYPE (uint64_t) | |
| bool | HelpRequested (const ArgsManager &args) |
| void | SetupHelpOptions (ArgsManager &args) |
| Add help options to the args manager. More... | |
| std::string | HelpMessageGroup (const std::string &message) |
| Format a string to be used as group of options in help messages. More... | |
| std::string | HelpMessageOpt (const std::string &option, const std::string &message) |
| Format a string to be used as option description in help messages. More... | |
| bool | HasTestOption (const ArgsManager &args, const std::string &test_option) |
| Checks if a particular test option is present in -test command-line arg options. More... | |
| fs::path | GetDefaultDataDir () |
| bool | CheckDataDirOption (const ArgsManager &args) |
Variables | |
| const char *const | BITCOIN_CONF_FILENAME = "bitcoin.conf" |
| const char *const | BITCOIN_SETTINGS_FILENAME = "settings.json" |
| ArgsManager | gArgs |
| static const int | screenWidth = 79 |
| static const int | optIndent = 2 |
| static const int | msgIndent = 7 |
| const std::vector< std::string > | TEST_OPTIONS_DOC |
| #define INSTANTIATE_INT_TYPE | ( | Type | ) |
| bool CheckDataDirOption | ( | const ArgsManager & | args | ) |
| fs::path GetDefaultDataDir | ( | ) |
| bool HasTestOption | ( | const ArgsManager & | args, |
| const std::string & | test_option | ||
| ) |
| std::string HelpMessageGroup | ( | const std::string & | message | ) |
| std::string HelpMessageOpt | ( | const std::string & | option, |
| const std::string & | message | ||
| ) |
Format a string to be used as option description in help messages.
| option | Option message (e.g. "-rpcuser=<user>") |
| message | Option description (e.g. "Username for JSON-RPC connections") |
Definition at line 736 of file args.cpp.
| bool HelpRequested | ( | const ArgsManager & | args | ) |
| INSTANTIATE_INT_TYPE | ( | int16_t | ) |
| INSTANTIATE_INT_TYPE | ( | int32_t | ) |
| INSTANTIATE_INT_TYPE | ( | int64_t | ) |
| INSTANTIATE_INT_TYPE | ( | int8_t | ) |
| INSTANTIATE_INT_TYPE | ( | uint16_t | ) |
| INSTANTIATE_INT_TYPE | ( | uint32_t | ) |
| INSTANTIATE_INT_TYPE | ( | uint64_t | ) |
| INSTANTIATE_INT_TYPE | ( | uint8_t | ) |
|
static |
Interpret a string argument as a boolean.
The definition of LocaleIndependentAtoi<int>() requires that non-numeric string values like "foo", return 0. This means that if a user unintentionally supplies a non-integer argument here, the return value is always false. This means that -foo=false does what the user probably expects, but -foo=true is well defined but does not do what they probably expected.
The return value of LocaleIndependentAtoi<int>(...) is zero when given input not representable as an int.
For a more extensive discussion of this topic (and a wide range of opinions on the Right Way to change this code), see PR12713.
Definition at line 57 of file args.cpp.
| KeyInfo InterpretKey | ( | std::string | key | ) |
Parse "name", "section.name", "noname", "section.noname" settings keys.
Definition at line 77 of file args.cpp.
| std::optional< common::SettingsValue > InterpretValue | ( | const KeyInfo & | key, |
| const std::string * | value, | ||
| unsigned int | flags, | ||
| std::string & | error | ||
| ) |
Interpret settings value based on registered flags.
| [in] | key | key information to know if key was negated |
| [in] | value | string value of setting to be parsed |
| [in] | flags | ArgsManager registered argument flags |
| [out] | error | Error description if settings value is not valid |
Definition at line 105 of file args.cpp.
|
static |
|
static |
| std::optional< Int > SettingTo | ( | const common::SettingsValue & | value | ) |
| Int SettingTo | ( | const common::SettingsValue & | value, |
| Int | nDefault | ||
| ) |
| std::optional< bool > SettingToBool | ( | const common::SettingsValue & | value | ) |
| bool SettingToBool | ( | const common::SettingsValue & | value, |
| bool | fDefault | ||
| ) |
| std::optional< std::string > SettingToString | ( | const common::SettingsValue & | value | ) |
| std::string SettingToString | ( | const common::SettingsValue & | value, |
| const std::string & | strDefault | ||
| ) |
| void SetupHelpOptions | ( | ArgsManager & | args | ) |
| const char* const BITCOIN_SETTINGS_FILENAME = "settings.json" |
| ArgsManager gArgs |
| const std::vector<std::string> TEST_OPTIONS_DOC |