BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ArgsManager Class Reference

#include <util.h>

Collaboration diagram for ArgsManager:
[legend]

Classes

struct  Arg
 

Public Member Functions

 ArgsManager ()
 
void SelectConfigNetwork (const std::string &network)
 Select the network in use. More...
 
bool ParseParameters (int argc, const char *const argv[], std::string &error)
 
bool ReadConfigFiles (std::string &error, bool ignore_invalid_keys=false)
 
void WarnForSectionOnlyArgs ()
 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::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)
 
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, const bool debug_only, const OptionsCategory &cat)
 Add argument. 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...
 
bool IsArgKnown (const std::string &key) const
 Check whether we know of this arg. More...
 

Protected Member Functions

std::map< std::string, std::vector< std::string > > m_override_args GUARDED_BY (cs_args)
 
std::map< std::string, std::vector< std::string > > m_config_args 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)
 
bool ReadConfigStream (std::istream &stream, std::string &error, bool ignore_invalid_keys=false)
 

Protected Attributes

CCriticalSection cs_args
 

Friends

class ArgsManagerHelper
 

Detailed Description

Definition at line 131 of file util.h.

Constructor & Destructor Documentation

◆ ArgsManager()

ArgsManager::ArgsManager ( )

Definition at line 359 of file util.cpp.

Member Function Documentation

◆ AddArg()

void ArgsManager::AddArg ( const std::string &  name,
const std::string &  help,
const bool  debug_only,
const OptionsCategory cat 
)

Add argument.

Definition at line 572 of file util.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 586 of file util.cpp.

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

◆ ClearArgs()

void ArgsManager::ClearArgs ( )
inline

Clear available arguments.

Definition at line 266 of file util.h.

◆ ForceSetArg()

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

Definition at line 566 of file util.cpp.

Here is the caller graph for this function:

◆ GetArg() [1/2]

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 526 of file util.cpp.

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

◆ GetArg() [2/2]

int64_t ArgsManager::GetArg ( const std::string &  strArg,
int64_t  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 534 of file util.cpp.

Here is the call 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 483 of file util.cpp.

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

◆ GetBoolArg()

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 542 of file util.cpp.

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

◆ GetChainName()

std::string ArgsManager::GetChainName ( ) const

Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.

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

Definition at line 967 of file util.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 593 of file util.cpp.

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

◆ GUARDED_BY() [1/5]

std::map<std::string, std::vector<std::string> > m_override_args ArgsManager::GUARDED_BY ( cs_args  )
protected

◆ GUARDED_BY() [2/5]

std::map<std::string, std::vector<std::string> > m_config_args ArgsManager::GUARDED_BY ( cs_args  )
protected

◆ GUARDED_BY() [3/5]

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

◆ GUARDED_BY() [4/5]

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

◆ GUARDED_BY() [5/5]

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

◆ IsArgKnown()

bool ArgsManager::IsArgKnown ( const std::string &  key) const

Check whether we know of this arg.

Definition at line 466 of file util.cpp.

◆ 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 508 of file util.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 502 of file util.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 411 of file util.cpp.

◆ ReadConfigFiles()

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

Definition at line 887 of file util.cpp.

Here is the call graph for this function:

◆ ReadConfigStream()

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

Definition at line 857 of file util.cpp.

Here is the caller graph for this function:

◆ SelectConfigNetwork()

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

Select the network in use.

Definition at line 405 of file util.cpp.

◆ 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 550 of file util.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 558 of file util.cpp.

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

◆ WarnForSectionOnlyArgs()

void ArgsManager::WarnForSectionOnlyArgs ( )

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 375 of file util.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ ArgsManagerHelper

friend class ArgsManagerHelper
friend

Definition at line 134 of file util.h.

Member Data Documentation

◆ cs_args

CCriticalSection ArgsManager::cs_args
mutableprotected

Definition at line 145 of file util.h.


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