Bitcoin Core  0.15.99
P2P Digital Currency
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ArgsManager Class Reference

#include <util.h>

Collaboration diagram for ArgsManager:
[legend]

Public Member Functions

 ArgsManager ()
 
void SelectConfigNetwork (const std::string &network)
 Select the network in use. More...
 
void ParseParameters (int argc, const char *const argv[])
 
void ReadConfigFile (const std::string &confPath)
 
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...
 

Protected Member Functions

void ReadConfigStream (std::istream &stream)
 

Protected Attributes

CCriticalSection cs_args
 
std::map< std::string, std::vector< std::string > > m_override_args
 
std::map< std::string, std::vector< std::string > > m_config_args
 
std::string m_network
 
std::set< std::string > m_network_only_args
 

Friends

class ArgsManagerHelper
 

Detailed Description

Definition at line 121 of file util.h.

Constructor & Destructor Documentation

ArgsManager::ArgsManager ( )

Definition at line 366 of file util.cpp.

Member Function Documentation

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

Definition at line 533 of file util.cpp.

Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

void ArgsManager::ParseParameters ( int  argc,
const char *const  argv[] 
)

Definition at line 415 of file util.cpp.

Here is the caller graph for this function:

void ArgsManager::ReadConfigFile ( const std::string &  confPath)

Definition at line 709 of file util.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ArgsManager::ReadConfigStream ( std::istream &  stream)
protected

Definition at line 690 of file util.cpp.

Here is the caller graph for this function:

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

Select the network in use.

Definition at line 410 of file util.cpp.

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ArgsManagerHelper
friend

Definition at line 124 of file util.h.

Member Data Documentation

CCriticalSection ArgsManager::cs_args
mutableprotected

Definition at line 126 of file util.h.

std::map<std::string, std::vector<std::string> > ArgsManager::m_config_args
protected

Definition at line 128 of file util.h.

std::string ArgsManager::m_network
protected

Definition at line 129 of file util.h.

std::set<std::string> ArgsManager::m_network_only_args
protected

Definition at line 130 of file util.h.

std::map<std::string, std::vector<std::string> > ArgsManager::m_override_args
protected

Definition at line 127 of file util.h.


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