![]() |
Bitcoin ABC
0.22.15
P2P Digital Currency
|
#include <system.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 | |
ArgsManager () | |
~ArgsManager () | |
void | SelectConfigNetwork (const std::string &network) |
Select the network in use. More... | |
NODISCARD bool | ParseParameters (int argc, const char *const argv[], std::string &error) |
NODISCARD 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. More... | |
const std::list< SectionInfo > | GetUnrecognizedSections () const |
Log warnings for unrecognized section names in the config file. More... | |
std::vector< std::string > | GetArgs (const std::string &strArg) const |
Return a vector of strings of the given argument. More... | |
bool | IsArgSet (const std::string &strArg) const |
Return true if the given argument has been manually set. More... | |
bool | IsArgNegated (const std::string &strArg) const |
Return true if the argument was originally passed as a negated option, i.e. More... | |
std::string | GetArg (const std::string &strArg, const std::string &strDefault) const |
Return string argument or default value. More... | |
int64_t | GetArg (const std::string &strArg, int64_t nDefault) const |
Return integer argument or default value. More... | |
bool | GetBoolArg (const std::string &strArg, bool fDefault) const |
Return boolean argument or default value. More... | |
bool | SoftSetArg (const std::string &strArg, const std::string &strValue) |
Set an argument if it doesn't already have a value. More... | |
bool | SoftSetBoolArg (const std::string &strArg, bool fValue) |
Set a boolean argument if it doesn't already have a value. More... | |
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 mapMultiArgs data structure. More... | |
std::string | GetChainName () const |
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name. More... | |
void | AddArg (const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat) |
Add argument. More... | |
void | ClearForcedArg (const std::string &strArg) |
Remove a forced arg setting, used only in testing. More... | |
void | AddHiddenArgs (const std::vector< std::string > &args) |
Add many hidden arguments. More... | |
void | ClearArgs () |
Clear available arguments. More... | |
std::string | GetHelpMessage () const |
Get the help string. More... | |
std::optional< unsigned int > | GetArgFlags (const std::string &name) const |
Return Flags for known arg. More... | |
bool | InitSettings (std::string &error) |
Read and update settings file with saved settings. More... | |
bool | GetSettingsPath (fs::path *filepath=nullptr, bool temp=false) const |
Get settings file path, or return false if read-write settings were disabled with -nosettings. More... | |
bool | ReadSettingsFile (std::vector< std::string > *errors=nullptr) |
Read settings file. More... | |
bool | WriteSettingsFile (std::vector< std::string > *errors=nullptr) const |
Write settings file. More... | |
template<typename Fn > | |
void | LockSettings (Fn &&fn) |
Access settings with lock held. More... | |
void | LogArgs () const |
Log the config file options and the command line arguments, useful for troubleshooting. More... | |
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) |
NODISCARD 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. More... | |
util::SettingsValue | GetSetting (const std::string &arg) const |
Get setting value. More... | |
std::vector< util::SettingsValue > | GetSettingsList (const std::string &arg) const |
Get list of setting values. More... | |
Protected Attributes | |
RecursiveMutex | cs_args |
Private Member Functions | |
void | logArgsPrefix (const std::string &prefix, const std::string §ion, const std::map< std::string, std::vector< util::SettingsValue >> &args) const |
enum ArgsManager::Flags |
ArgsManager::ArgsManager | ( | ) |
Definition at line 248 of file system.cpp.
ArgsManager::~ArgsManager | ( | ) |
Definition at line 249 of file system.cpp.
void ArgsManager::AddArg | ( | const std::string & | name, |
const std::string & | help, | ||
unsigned int | flags, | ||
const OptionsCategory & | cat | ||
) |
Add argument.
Definition at line 547 of file system.cpp.
void ArgsManager::AddHiddenArgs | ( | const std::vector< std::string > & | args | ) |
Add many hidden arguments.
Definition at line 569 of file system.cpp.
|
inline |
void ArgsManager::ClearForcedArg | ( | const std::string & | strArg | ) |
Remove a forced arg setting, used only in testing.
Definition at line 575 of file system.cpp.
void ArgsManager::ForceSetArg | ( | const std::string & | strArg, |
const std::string & | strValue | ||
) |
Definition at line 524 of file system.cpp.
void ArgsManager::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 mapMultiArgs data structure.
Definition at line 535 of file system.cpp.
std::string ArgsManager::GetArg | ( | const std::string & | strArg, |
const std::string & | strDefault | ||
) | const |
Return string argument or default value.
strArg | Argument to get (e.g. "-foo") |
strDefault | (e.g. "1") |
Definition at line 480 of file system.cpp.
int64_t ArgsManager::GetArg | ( | const std::string & | strArg, |
int64_t | nDefault | ||
) | const |
Return integer argument or default value.
strArg | Argument to get (e.g. "-foo") |
nDefault | (e.g. 1) |
Definition at line 488 of file system.cpp.
std::optional< unsigned int > ArgsManager::GetArgFlags | ( | const std::string & | name | ) | const |
Return Flags for known arg.
Return std::nullopt for unknown arg.
Definition at line 371 of file system.cpp.
std::vector< std::string > ArgsManager::GetArgs | ( | const std::string & | strArg | ) | const |
Return a vector of strings of the given argument.
strArg | Argument to get (e.g. "-foo") |
Definition at line 382 of file system.cpp.
bool ArgsManager::GetBoolArg | ( | const std::string & | strArg, |
bool | fDefault | ||
) | const |
Return boolean argument or default value.
strArg | Argument to get (e.g. "-foo") |
fDefault | (true or false) |
Definition at line 499 of file system.cpp.
std::string ArgsManager::GetChainName | ( | ) | const |
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition at line 1015 of file system.cpp.
std::string ArgsManager::GetHelpMessage | ( | ) | const |
Get the help string.
Definition at line 580 of file system.cpp.
|
protected |
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 1049 of file system.cpp.
|
protected |
Get list of setting values.
Definition at line 1057 of file system.cpp.
bool ArgsManager::GetSettingsPath | ( | fs::path * | filepath = nullptr , |
bool | temp = false |
||
) | const |
Get settings file path, or return false if read-write settings were disabled with -nosettings.
Definition at line 414 of file system.cpp.
const std::list< SectionInfo > ArgsManager::GetUnrecognizedSections | ( | ) | const |
Log warnings for unrecognized section names in the config file.
Definition at line 275 of file system.cpp.
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 251 of file system.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
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 395 of file system.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 476 of file system.cpp.
bool ArgsManager::IsArgSet | ( | const std::string & | strArg | ) | const |
Return true if the given argument has been manually set.
strArg | Argument to get (e.g. "-foo") |
Definition at line 391 of file system.cpp.
|
inline |
void ArgsManager::LogArgs | ( | ) | const |
Log the config file options and the command line arguments, useful for troubleshooting.
Definition at line 1080 of file system.cpp.
|
private |
Definition at line 1063 of file system.cpp.
bool ArgsManager::ParseParameters | ( | int | argc, |
const char *const | argv[], | ||
std::string & | error | ||
) |
Definition at line 319 of file system.cpp.
bool ArgsManager::ReadConfigFiles | ( | std::string & | error, |
bool | ignore_invalid_keys = false |
||
) |
Definition at line 912 of file system.cpp.
|
protected |
Definition at line 877 of file system.cpp.
bool ArgsManager::ReadSettingsFile | ( | std::vector< std::string > * | errors = nullptr | ) |
Read settings file.
Push errors to vector, or log them if null.
Definition at line 437 of file system.cpp.
void ArgsManager::SelectConfigNetwork | ( | const std::string & | network | ) |
Select the network in use.
Definition at line 290 of file system.cpp.
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 506 of file system.cpp.
bool ArgsManager::SoftSetBoolArg | ( | const std::string & | strArg, |
bool | fValue | ||
) |
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 516 of file system.cpp.
|
protected |
Returns true if settings values from the default section should be used, depending on the current network and whether the setting is network-specific.
Definition at line 1044 of file system.cpp.
bool ArgsManager::WriteSettingsFile | ( | std::vector< std::string > * | errors = nullptr | ) | const |
Write settings file.
Push errors to vector, or log them if null.
Definition at line 453 of file system.cpp.
|
mutableprotected |