Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ArgsManager Class Reference

#include <args.h>

Inheritance diagram for ArgsManager:
[legend]
Collaboration diagram for ArgsManager:
[legend]

Classes

struct  Arg
 
struct  Command
 

Public Types

enum  Flags : uint32_t {
  ALLOW_ANY = 0x01 , DISALLOW_NEGATION = 0x20 , DISALLOW_ELISION = 0x40 , DEBUG_ONLY = 0x100 ,
  NETWORK_ONLY = 0x200 , SENSITIVE = 0x400 , COMMAND = 0x800
}
 Flags controlling how config and command line arguments are validated and interpreted. More...
 

Public Member Functions

common::SettingsValue GetSetting (const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get setting value. More...
 
std::vector< common::SettingsValueGetSettingsList (const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get list of setting values. More...
 
 ArgsManager ()
 
 ~ArgsManager ()
 
void SelectConfigNetwork (const std::string &network) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Select the network in use. More...
 
bool ParseParameters (int argc, const char *const argv[], std::string &error) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
fs::path GetConfigFilePath () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return config file path (read-only) More...
 
void SetConfigFilePath (fs::path) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
bool ReadConfigFiles (std::string &error, bool ignore_invalid_keys=false) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
std::set< std::string > GetUnsuitableSectionOnlyArgs () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 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...
 
std::list< SectionInfoGetUnrecognizedSections () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Log warnings for unrecognized section names in the config file. More...
 
std::optional< const CommandGetCommand () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get the command and command args (returns std::nullopt if no command provided) More...
 
fs::path GetBlocksDirPath () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get blocks directory path. More...
 
fs::path GetDataDirBase () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get data directory path. More...
 
fs::path GetDataDirNet () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get data directory path with appended network identifier. More...
 
void ClearPathCache () EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Clear cached directory paths. More...
 
std::vector< std::string > GetArgs (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return a vector of strings of the given argument. More...
 
bool IsArgSet (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return true if the given argument has been manually set. More...
 
bool IsArgNegated (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 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 EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return string argument or default value. More...
 
std::optional< std::string > GetArg (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
fs::path GetPathArg (std::string arg, const fs::path &default_value={}) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return path argument or default value. More...
 
template<std::integral Int>
Int GetArg (const std::string &strArg, Int nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return integer argument or default value. More...
 
template<std::integral Int>
std::optional< Int > GetArg (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
int64_t GetIntArg (const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
std::optional< int64_t > GetIntArg (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
bool GetBoolArg (const std::string &strArg, bool fDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return boolean argument or default value. More...
 
std::optional< bool > GetBoolArg (const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
bool SoftSetArg (const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Set an argument if it doesn't already have a value. More...
 
bool SoftSetBoolArg (const std::string &strArg, bool fValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Set a boolean argument if it doesn't already have a value. More...
 
void ForceSetArg (const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
ChainType GetChainType () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Returns the appropriate chain type from the program arguments. More...
 
std::string GetChainTypeString () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Returns the appropriate chain type string from the program arguments. More...
 
void AddArg (const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Add argument. More...
 
void AddCommand (const std::string &cmd, const std::string &help) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Add subcommand. More...
 
void AddHiddenArgs (const std::vector< std::string > &args) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Add many hidden arguments. More...
 
void ClearArgs () EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Clear available arguments. More...
 
void CheckMultipleCLIArgs () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Check CLI command args. More...
 
std::string GetHelpMessage () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get the help string. More...
 
std::optional< unsigned int > GetArgFlags (const std::string &name) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return Flags for known arg. More...
 
void SetDefaultFlags (std::optional< unsigned int >) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Set default flags to return for an unknown arg. More...
 
bool GetSettingsPath (fs::path *filepath=nullptr, bool temp=false, bool backup=false) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get settings file path, or return false if read-write settings were disabled with -nosettings. More...
 
bool ReadSettingsFile (std::vector< std::string > *errors=nullptr) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Read settings file. More...
 
bool WriteSettingsFile (std::vector< std::string > *errors=nullptr, bool backup=false) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Write settings file or backup settings file. More...
 
common::SettingsValue GetPersistentSetting (const std::string &name) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Get current setting from config file or read/write settings file, ignoring nonpersistent command line or forced settings values. More...
 
template<typename Fn >
void LockSettings (Fn &&fn) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Access settings with lock held. More...
 
void LogArgs () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Log the config file options and the command line arguments, useful for troubleshooting. More...
 

Protected Member Functions

bool ReadConfigStream (std::istream &stream, const std::string &filepath, std::string &error, bool ignore_invalid_keys=false) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 
bool ReadConfigString (const std::string &str_config) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 

Private Member Functions

common::Settings m_settings GUARDED_BY (cs_args)
 
std::vector< std::string > m_command 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::optional< unsigned int > m_default_flags GUARDED_BY (cs_args)
 
bool m_accept_any_command GUARDED_BY (cs_args)
 
std::list< SectionInfo > m_config_sections GUARDED_BY (cs_args)
 
std::optional< fs::path > m_config_path 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 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...
 
common::SettingsValue GetSetting_ (const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
 
std::optional< unsigned int > GetArgFlags_ (const std::string &name) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
 
fs::path GetPathArg_ (std::string arg, const fs::path &default_value={}) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
 
fs::path GetDataDir (bool net_specific) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
 Get data directory path. More...
 
std::variant< ChainType, std::string > GetChainArg () const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
 Return -regtest/-signet/-testnet/-testnet4/-chain= setting as a ChainType enum if a recognized chain type was set, or as a string if an unrecognized chain name was set. More...
 
void logArgsPrefix (const std::string &prefix, const std::string &section, const std::map< std::string, std::vector< common::SettingsValue > > &args) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
 

Private Attributes

Mutex cs_args
 

Detailed Description

Definition at line 102 of file args.h.

Member Enumeration Documentation

◆ Flags

enum ArgsManager::Flags : uint32_t

Flags controlling how config and command line arguments are validated and interpreted.

Enumerator
ALLOW_ANY 

disable validation

DISALLOW_NEGATION 

disallow -nofoo syntax

DISALLOW_ELISION 

disallow -foo syntax that doesn't assign any value

DEBUG_ONLY 
NETWORK_ONLY 
SENSITIVE 
COMMAND 

Definition at line 109 of file args.h.

Constructor & Destructor Documentation

◆ ArgsManager()

ArgsManager::ArgsManager ( )
default

◆ ~ArgsManager()

ArgsManager::~ArgsManager ( )
default

Member Function Documentation

◆ AddArg()

void ArgsManager::AddArg ( const std::string &  name,
const std::string &  help,
unsigned int  flags,
const OptionsCategory cat 
)

Add argument.

Definition at line 613 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddCommand()

void ArgsManager::AddCommand ( const std::string &  cmd,
const std::string &  help 
)

Add subcommand.

Definition at line 601 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddHiddenArgs()

void ArgsManager::AddHiddenArgs ( const std::vector< std::string > &  args)

Add many hidden arguments.

Definition at line 634 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckMultipleCLIArgs()

void ArgsManager::CheckMultipleCLIArgs ( ) const

Check CLI command args.

Exceptions
std::runtime_errorwhen multiple CLI_COMMAND arguments are specified

Definition at line 650 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearArgs()

void ArgsManager::ClearArgs ( )

Clear available arguments.

Definition at line 641 of file args.cpp.

Here is the caller graph for this function:

◆ ClearPathCache()

void ArgsManager::ClearPathCache ( )

Clear cached directory paths.

Definition at line 361 of file args.cpp.

Here is the caller graph for this function:

◆ ForceSetArg()

void ArgsManager::ForceSetArg ( const std::string &  strArg,
const std::string &  strValue 
)

Definition at line 595 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetArg() [1/4]

std::optional< std::string > ArgsManager::GetArg ( const std::string &  strArg) const

Definition at line 490 of file args.cpp.

Here is the call graph for this function:

◆ GetArg() [2/4]

template<std::integral Int>
std::optional< Int > ArgsManager::GetArg ( const std::string &  strArg) const

Definition at line 517 of file args.cpp.

Here is the call graph for this function:

◆ GetArg() [3/4]

std::string ArgsManager::GetArg ( const std::string &  strArg,
const std::string &  strDefault 
) const

Return string argument or default value.

Parameters
strArgArgument to get (e.g. "-foo")
strDefault(e.g. "1")
Returns
command-line argument or default value

Definition at line 485 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetArg() [4/4]

template<std::integral Int>
Int ArgsManager::GetArg ( const std::string &  strArg,
Int  nDefault 
) const

Return integer argument or default value.

Parameters
strArgArgument to get (e.g. "-foo")
nDefault(e.g. 1)
Returns
command-line argument (0 if invalid number) or default value

Definition at line 511 of file args.cpp.

◆ GetArgFlags()

std::optional< unsigned int > ArgsManager::GetArgFlags ( const std::string &  name) const

Return Flags for known arg.

Return default flags for unknown arg.

Definition at line 270 of file args.cpp.

Here is the call graph for this function:

◆ GetArgFlags_()

std::optional< unsigned int > ArgsManager::GetArgFlags_ ( const std::string &  name) const
private

Definition at line 258 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetArgs()

std::vector< std::string > ArgsManager::GetArgs ( const std::string &  strArg) const

Return a vector of strings of the given argument.

Parameters
strArgArgument to get (e.g. "-foo")
Returns
command-line arguments

Definition at line 390 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlocksDirPath()

fs::path ArgsManager::GetBlocksDirPath ( ) const

Get blocks directory path.

Returns
Blocks path which is network specific

Definition at line 300 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBoolArg() [1/2]

std::optional< bool > ArgsManager::GetBoolArg ( const std::string &  strArg) const

Definition at line 544 of file args.cpp.

Here is the call graph for this function:

◆ GetBoolArg() [2/2]

bool ArgsManager::GetBoolArg ( const std::string &  strArg,
bool  fDefault 
) const

Return boolean argument or default value.

Parameters
strArgArgument to get (e.g. "-foo")
fDefault(true or false)
Returns
command-line argument or default value

Definition at line 539 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChainArg()

std::variant< ChainType, std::string > ArgsManager::GetChainArg ( ) const
private

Return -regtest/-signet/-testnet/-testnet4/-chain= setting as a ChainType enum if a recognized chain type was set, or as a string if an unrecognized chain name was set.

Raise an exception if an invalid combination of flags was provided.

Definition at line 847 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChainType()

ChainType ArgsManager::GetChainType ( ) const

Returns the appropriate chain type from the program arguments.

Returns
ChainType::MAIN by default; raises runtime error if an invalid combination, or unknown chain is given.

Definition at line 833 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChainTypeString()

std::string ArgsManager::GetChainTypeString ( ) const

Returns the appropriate chain type string from the program arguments.

Returns
ChainType::MAIN string by default; raises runtime error if an invalid combination is given.

Definition at line 840 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCommand()

std::optional< const ArgsManager::Command > ArgsManager::GetCommand ( ) const

Get the command and command args (returns std::nullopt if no command provided)

Definition at line 370 of file args.cpp.

◆ GetConfigFilePath()

fs::path ArgsManager::GetConfigFilePath ( ) const

Return config file path (read-only)

Definition at line 820 of file args.cpp.

Here is the caller graph for this function:

◆ GetDataDir()

fs::path ArgsManager::GetDataDir ( bool  net_specific) const
private

Get data directory path.

Parameters
net_specificAppend network identifier to the returned path
Returns
Absolute path on success, otherwise an empty path when a non-directory path would be returned

Definition at line 335 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDataDirBase()

fs::path ArgsManager::GetDataDirBase ( ) const

Get data directory path.

Returns
Absolute path on success, otherwise an empty path when a non-directory path would be returned

Definition at line 325 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDataDirNet()

fs::path ArgsManager::GetDataDirNet ( ) const

Get data directory path with appended network identifier.

Returns
Absolute path on success, otherwise an empty path when a non-directory path would be returned

Definition at line 330 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHelpMessage()

std::string ArgsManager::GetHelpMessage ( ) const

Get the help string.

Definition at line 667 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIntArg() [1/2]

std::optional< int64_t > ArgsManager::GetIntArg ( const std::string &  strArg) const
inline

Definition at line 309 of file args.h.

◆ GetIntArg() [2/2]

int64_t ArgsManager::GetIntArg ( const std::string &  strArg,
int64_t  nDefault 
) const
inline

Definition at line 308 of file args.h.

Here is the caller graph for this function:

◆ GetPathArg()

fs::path ArgsManager::GetPathArg ( std::string  arg,
const fs::path default_value = {} 
) const

Return path argument or default value.

Parameters
argArgument to get a path from (e.g., "-datadir", "-blocksdir" or "-walletdir")
default_valueOptional default value to return instead of the empty path.
Returns
normalized path if argument is set, with redundant "." and ".." path components and trailing separators removed (see patharg unit test for examples or implementation for details). If argument is empty or not set, default_value is returned unchanged.

Definition at line 294 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPathArg_()

fs::path ArgsManager::GetPathArg_ ( std::string  arg,
const fs::path default_value = {} 
) const
private

Definition at line 282 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPersistentSetting()

common::SettingsValue ArgsManager::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.

Definition at line 473 of file args.cpp.

Here is the call graph for this function:

◆ GetSetting()

common::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 893 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSetting_()

common::SettingsValue ArgsManager::GetSetting_ ( const std::string &  arg) const
private

Definition at line 885 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSettingsList()

std::vector< common::SettingsValue > ArgsManager::GetSettingsList ( const std::string &  arg) const

Get list of setting values.

Definition at line 899 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSettingsPath()

bool ArgsManager::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.

Definition at line 404 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUnrecognizedSections()

std::list< SectionInfo > ArgsManager::GetUnrecognizedSections ( ) const

Log warnings for unrecognized section names in the config file.

Definition at line 154 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUnsuitableSectionOnlyArgs()

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 134 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GUARDED_BY() [1/12]

common::Settings m_settings ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [2/12]

std::vector< std::string > m_command ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [3/12]

std::string m_network ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [4/12]

std::set< std::string > m_network_only_args ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [5/12]

std::map< OptionsCategory, std::map< std::string, Arg > > m_available_args ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [6/12]

std::optional< unsigned int > m_default_flags ArgsManager::GUARDED_BY ( cs_args  )
inlineprivate

Definition at line 144 of file args.h.

◆ GUARDED_BY() [7/12]

bool m_accept_any_command ArgsManager::GUARDED_BY ( cs_args  )
inlineprivate

Definition at line 145 of file args.h.

◆ GUARDED_BY() [8/12]

std::list< SectionInfo > m_config_sections ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [9/12]

std::optional< fs::path > m_config_path ArgsManager::GUARDED_BY ( cs_args  )
private

◆ GUARDED_BY() [10/12]

fs::path m_cached_blocks_path ArgsManager::GUARDED_BY ( cs_args  )
mutableprivate

◆ GUARDED_BY() [11/12]

fs::path m_cached_datadir_path ArgsManager::GUARDED_BY ( cs_args  )
mutableprivate

◆ GUARDED_BY() [12/12]

fs::path m_cached_network_datadir_path ArgsManager::GUARDED_BY ( cs_args  )
mutableprivate

◆ IsArgNegated()

bool ArgsManager::IsArgNegated ( const std::string &  strArg) const

Return true if the argument was originally passed as a negated option, i.e.

-nofoo.

Parameters
strArgArgument to get (e.g. "-foo")
Returns
true if the argument was passed negated

Definition at line 480 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsArgSet()

bool ArgsManager::IsArgSet ( const std::string &  strArg) const

Return true if the given argument has been manually set.

Parameters
strArgArgument to get (e.g. "-foo")
Returns
true if the argument has been set

Definition at line 399 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LockSettings()

template<typename Fn >
void ArgsManager::LockSettings ( Fn &&  fn)
inline

Access settings with lock held.

Definition at line 427 of file args.h.

Here is the caller graph for this function:

◆ LogArgs()

void ArgsManager::LogArgs ( ) const

Log the config file options and the command line arguments, useful for troubleshooting.

Definition at line 923 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logArgsPrefix()

void ArgsManager::logArgsPrefix ( const std::string &  prefix,
const std::string &  section,
const std::map< std::string, std::vector< common::SettingsValue > > &  args 
) const
private

Definition at line 905 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseParameters()

bool ArgsManager::ParseParameters ( int  argc,
const char *const  argv[],
std::string &  error 
)

Definition at line 177 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadConfigFiles()

bool ArgsManager::ReadConfigFiles ( std::string &  error,
bool  ignore_invalid_keys = false 
)

Definition at line 135 of file config.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadConfigStream()

bool ArgsManager::ReadConfigStream ( std::istream &  stream,
const std::string &  filepath,
std::string &  error,
bool  ignore_invalid_keys = false 
)
protected

Definition at line 94 of file config.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadConfigString()

bool ArgsManager::ReadConfigString ( const std::string &  str_config)
protected

Definition at line 123 of file config.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSettingsFile()

bool ArgsManager::ReadSettingsFile ( std::vector< std::string > *  errors = nullptr)

Read settings file.

Push errors to vector, or log them if null.

Definition at line 430 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectConfigNetwork()

void ArgsManager::SelectConfigNetwork ( const std::string &  network)

Select the network in use.

Definition at line 171 of file args.cpp.

Here is the caller graph for this function:

◆ SetConfigFilePath()

void ArgsManager::SetConfigFilePath ( fs::path  path)

Definition at line 826 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDefaultFlags()

void ArgsManager::SetDefaultFlags ( std::optional< unsigned int >  flags)

Set default flags to return for an unknown arg.

Definition at line 276 of file args.cpp.

Here is the caller graph for this function:

◆ SoftSetArg()

bool ArgsManager::SoftSetArg ( const std::string &  strArg,
const std::string &  strValue 
)

Set an argument if it doesn't already have a value.

Parameters
strArgArgument to set (e.g. "-foo")
strValueValue (e.g. "1")
Returns
true if argument gets set, false if it already had a value

Definition at line 579 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SoftSetBoolArg()

bool ArgsManager::SoftSetBoolArg ( const std::string &  strArg,
bool  fValue 
)

Set a boolean argument if it doesn't already have a value.

Parameters
strArgArgument to set (e.g. "-foo")
fValueValue (e.g. false)
Returns
true if argument gets set, false if it already had a value

Definition at line 587 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UseDefaultSection()

bool ArgsManager::UseDefaultSection ( const std::string &  arg) const
private

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 879 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteSettingsFile()

bool ArgsManager::WriteSettingsFile ( std::vector< std::string > *  errors = nullptr,
bool  backup = false 
) const

Write settings file or backup settings file.

Push errors to vector, or log them if null.

Definition at line 453 of file args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cs_args

Mutex ArgsManager::cs_args
mutableprivate

Definition at line 138 of file args.h.


The documentation for this class was generated from the following files: