Bitcoin ABC 0.26.3
P2P Digital Currency
|
#include <args.h>
Classes | |
struct | Arg |
Public Types | |
enum | Flags { ALLOW_BOOL = 0x01 , ALLOW_INT = 0x02 , ALLOW_STRING = 0x04 , ALLOW_ANY = ALLOW_BOOL | ALLOW_INT | ALLOW_STRING , DEBUG_ONLY = 0x100 , NETWORK_ONLY = 0x200 , SENSITIVE = 0x400 } |
Public Member Functions | |
util::SettingsValue | GetSetting (const std::string &arg) const |
Get setting value. | |
std::vector< util::SettingsValue > | GetSettingsList (const std::string &arg) const |
Get list of setting values. | |
ArgsManager () | |
~ArgsManager () | |
void | SelectConfigNetwork (const std::string &network) |
Select the network in use. | |
bool | ParseParameters (int argc, const char *const argv[], std::string &error) |
fs::path | GetConfigFilePath () const |
Return config file path (read-only) | |
bool | ReadConfigFiles (std::string &error, bool ignore_invalid_keys=false) |
const std::set< std::string > | GetUnsuitableSectionOnlyArgs () const |
Log warnings for options in m_section_only_args when they are specified in the default section but not overridden on the command line or in a network-specific section in the config file. | |
const std::list< SectionInfo > | GetUnrecognizedSections () const |
Log warnings for unrecognized section names in the config file. | |
fs::path | GetBlocksDirPath () const |
Get blocks directory path. | |
fs::path | GetDataDirBase () const |
Get data directory path. | |
fs::path | GetDataDirNet () const |
Get data directory path with appended network identifier. | |
void | ClearPathCache () |
Clear cached directory paths. | |
std::vector< std::string > | GetArgs (const std::string &strArg) const |
Return a vector of strings of the given argument. | |
bool | IsArgSet (const std::string &strArg) const |
Return true if the given argument has been manually set. | |
bool | IsArgNegated (const std::string &strArg) const |
Return true if the argument was originally passed as a negated option, i.e. | |
std::string | GetArg (const std::string &strArg, const std::string &strDefault) const |
Return string argument or default value. | |
std::optional< std::string > | GetArg (const std::string &strArg) const |
fs::path | GetPathArg (std::string arg, const fs::path &default_value={}) const |
Return path argument or default value. | |
int64_t | GetIntArg (const std::string &strArg, int64_t nDefault) const |
Return integer argument or default value. | |
std::optional< int64_t > | GetIntArg (const std::string &strArg) const |
bool | GetBoolArg (const std::string &strArg, bool fDefault) const |
Return boolean argument or default value. | |
std::optional< bool > | GetBoolArg (const std::string &strArg) const |
bool | SoftSetArg (const std::string &strArg, const std::string &strValue) |
Set an argument if it doesn't already have a value. | |
bool | SoftSetBoolArg (const std::string &strArg, bool fValue) |
Set a boolean argument if it doesn't already have a value. | |
void | ForceSetArg (const std::string &strArg, const std::string &strValue) |
void | ForceSetMultiArg (const std::string &strArg, const std::vector< std::string > &values) |
This function is only used for testing purpose so so we should not worry about element uniqueness and integrity of the data structure. | |
std::string | GetChainName () const |
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name. | |
void | AddArg (const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat) |
Add argument. | |
void | ClearForcedArg (const std::string &strArg) |
Remove a forced arg setting, used only in testing. | |
void | AddHiddenArgs (const std::vector< std::string > &args) |
Add many hidden arguments. | |
void | ClearArgs () |
Clear available arguments. | |
std::string | GetHelpMessage () const |
Get the help string. | |
std::optional< unsigned int > | GetArgFlags (const std::string &name) const |
Return Flags for known arg. | |
bool | InitSettings (std::string &error) |
Read and update settings file with saved settings. | |
bool | GetSettingsPath (fs::path *filepath=nullptr, bool temp=false, bool backup=false) const |
Get settings file path, or return false if read-write settings were disabled with -nosettings. | |
bool | ReadSettingsFile (std::vector< std::string > *errors=nullptr) |
Read settings file. | |
bool | WriteSettingsFile (std::vector< std::string > *errors=nullptr, bool backup=false) const |
Write settings file or backup settings file. | |
util::SettingsValue | GetPersistentSetting (const std::string &name) const |
Get current setting from config file or read/write settings file, ignoring nonpersistent command line or forced settings values. | |
template<typename Fn > | |
void | LockSettings (Fn &&fn) |
Access settings with lock held. | |
void | LogArgs () const |
Log the config file options and the command line arguments, useful for troubleshooting. | |
void | EnsureDataDir () const |
If datadir does not exist, create it along with wallets/ subdirectory(s). | |
Protected Member Functions | |
util::Settings m_settings | GUARDED_BY (cs_args) |
std::string m_network | GUARDED_BY (cs_args) |
std::set< std::string > m_network_only_args | GUARDED_BY (cs_args) |
std::map< OptionsCategory, std::map< std::string, Arg > > m_available_args | GUARDED_BY (cs_args) |
std::list< SectionInfo > m_config_sections | GUARDED_BY (cs_args) |
fs::path m_cached_blocks_path | GUARDED_BY (cs_args) |
fs::path m_cached_datadir_path | GUARDED_BY (cs_args) |
fs::path m_cached_network_datadir_path | GUARDED_BY (cs_args) |
bool | ReadConfigStream (std::istream &stream, const std::string &filepath, std::string &error, bool ignore_invalid_keys=false) |
bool | UseDefaultSection (const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(cs_args) |
Returns true if settings values from the default section should be used, depending on the current network and whether the setting is network-specific. | |
Protected Attributes | |
RecursiveMutex | cs_args |
Private Member Functions | |
fs::path | GetDataDir (bool net_specific) const |
Get data directory path. | |
void | logArgsPrefix (const std::string &prefix, const std::string §ion, const std::map< std::string, std::vector< util::SettingsValue > > &args) const |
void ArgsManager::AddArg | ( | const std::string & | name, |
const std::string & | help, | ||
unsigned int | flags, | ||
const OptionsCategory & | cat | ||
) |
void ArgsManager::AddHiddenArgs | ( | const std::vector< std::string > & | args | ) |
|
inline |
void ArgsManager::ClearForcedArg | ( | const std::string & | strArg | ) |
void ArgsManager::ClearPathCache | ( | ) |
void ArgsManager::EnsureDataDir | ( | ) | const |
If datadir does not exist, create it along with wallets/ subdirectory(s).
"/wallets" subdirectories are created in all new datadirs, because wallet code will create new wallets in the "wallets" subdirectory only if exists already, otherwise it will create them in the top-level datadir where they could interfere with other files. Wallet init code currently avoids creating "wallets" directories itself for backwards compatibility, but this be changed in the future and wallet code here could go away.
Definition at line 343 of file args.cpp.
void ArgsManager::ForceSetArg | ( | const std::string & | strArg, |
const std::string & | strValue | ||
) |
void ArgsManager::ForceSetMultiArg | ( | const std::string & | strArg, |
const std::vector< std::string > & | values | ||
) |
std::optional< std::string > ArgsManager::GetArg | ( | const std::string & | strArg | ) | const |
std::string ArgsManager::GetArg | ( | const std::string & | strArg, |
const std::string & | strDefault | ||
) | const |
std::vector< std::string > ArgsManager::GetArgs | ( | const std::string & | strArg | ) | const |
fs::path ArgsManager::GetBlocksDirPath | ( | ) | const |
std::optional< bool > ArgsManager::GetBoolArg | ( | const std::string & | strArg | ) | const |
std::string ArgsManager::GetChainName | ( | ) | const |
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition at line 793 of file args.cpp.
fs::path ArgsManager::GetConfigFilePath | ( | ) | const |
Get data directory path.
net_specific | Append network identifier to the returned path |
Definition at line 315 of file args.cpp.
|
inline |
Get data directory path.
Definition at line 206 of file args.h.
|
inline |
Get data directory path with appended network identifier.
Definition at line 215 of file args.h.
std::string ArgsManager::GetHelpMessage | ( | ) | const |
std::optional< int64_t > ArgsManager::GetIntArg | ( | const std::string & | strArg | ) | const |
Return integer argument or default value.
strArg | Argument to get (e.g. "-foo") |
nDefault | (e.g. 1) |
Definition at line 526 of file args.cpp.
Return path argument or default value.
arg | Argument to get a path from (e.g., "-datadir", "-blocksdir" or "-walletdir") |
default_value | Optional default value to return instead of the empty path. |
Definition at line 275 of file args.cpp.
util::SettingsValue ArgsManager::GetPersistentSetting | ( | const std::string & | name | ) | const |
util::SettingsValue ArgsManager::GetSetting | ( | const std::string & | arg | ) | const |
Get setting value.
Result will be null if setting was unset, true if "-setting" argument was passed false if "-nosetting" argument was passed, and a string if a "-setting=value" argument was passed.
Definition at line 828 of file args.cpp.
std::vector< util::SettingsValue > ArgsManager::GetSettingsList | ( | const std::string & | arg | ) | const |
const std::list< SectionInfo > ArgsManager::GetUnrecognizedSections | ( | ) | const |
const std::set< std::string > ArgsManager::GetUnsuitableSectionOnlyArgs | ( | ) | const |
Log warnings for options in m_section_only_args when they are specified in the default section but not overridden on the command line or in a network-specific section in the config file.
Definition at line 133 of file args.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
mutableprotected |
bool ArgsManager::InitSettings | ( | std::string & | error | ) |
Read and update settings file with saved settings.
This needs to be called after SelectParams() because the settings file location is network-specific.
Definition at line 385 of file args.cpp.
bool ArgsManager::IsArgNegated | ( | const std::string & | strArg | ) | const |
Return true if the argument was originally passed as a negated option, i.e.
-nofoo.
strArg | Argument to get (e.g. "-foo") |
Definition at line 490 of file args.cpp.
bool ArgsManager::IsArgSet | ( | const std::string & | strArg | ) | const |
void ArgsManager::LogArgs | ( | ) | const |
|
private |
Definition at line 132 of file configfile.cpp.
|
protected |
Definition at line 97 of file configfile.cpp.
void ArgsManager::SelectConfigNetwork | ( | const std::string & | network | ) |
bool ArgsManager::SoftSetArg | ( | const std::string & | strArg, |
const std::string & | strValue | ||
) |
Set an argument if it doesn't already have a value.
strArg | Argument to set (e.g. "-foo") |
strValue | Value (e.g. "1") |
Definition at line 579 of file args.cpp.
Set a boolean argument if it doesn't already have a value.
strArg | Argument to set (e.g. "-foo") |
fValue | Value (e.g. false) |
Definition at line 589 of file args.cpp.
|
protected |
|
mutableprotected |