Bitcoin ABC  0.26.3
P2P Digital Currency
Classes | Namespaces | Enumerations | Functions | Variables
args.h File Reference
#include <compat.h>
#include <sync.h>
#include <util/fs.h>
#include <util/settings.h>
#include <cstdint>
#include <iosfwd>
#include <list>
#include <map>
#include <optional>
#include <set>
#include <string>
#include <vector>
Include dependency graph for args.h:

Go to the source code of this file.

Classes

struct  SectionInfo
 
class  ArgsManager
 
struct  ArgsManager::Arg
 

Namespaces

 common
 

Enumerations

enum class  OptionsCategory {
  OPTIONS , CONNECTION , WALLET , WALLET_DEBUG_TEST ,
  ZMQ , DEBUG_TEST , CHAINPARAMS , NODE_RELAY ,
  BLOCK_CREATION , RPC , GUI , COMMANDS ,
  REGISTER_COMMANDS , AVALANCHE , CHRONIK , HIDDEN
}
 

Functions

bool CheckDataDirOption (const ArgsManager &args)
 
fs::path GetConfigFile (const ArgsManager &args, const fs::path &configuration_file_path)
 
bool ParseKeyValue (std::string &key, std::string &val)
 
fs::path AbsPathForConfigVal (const ArgsManager &args, const fs::path &path, bool net_specific=true)
 Most paths passed as configuration arguments are treated as relative to the datadir if they are not absolute. More...
 
bool IsSwitchChar (char c)
 
bool CheckValid (const std::string &key, const util::SettingsValue &val, unsigned int flags, std::string &error)
 Check settings value validity according to flags. More...
 
util::SettingsValue InterpretOption (std::string &section, std::string &key, const std::string &value)
 Interpret -nofoo as if the user supplied -foo=0. More...
 
std::string SettingToString (const util::SettingsValue &, const std::string &)
 
std::optional< std::string > SettingToString (const util::SettingsValue &)
 
int64_t SettingToInt (const util::SettingsValue &, int64_t)
 
std::optional< int64_t > SettingToInt (const util::SettingsValue &)
 
bool SettingToBool (const util::SettingsValue &, bool)
 
std::optional< bool > SettingToBool (const util::SettingsValue &)
 
bool HelpRequested (const ArgsManager &args)
 
void SetupHelpOptions (ArgsManager &args)
 Add help options to the args manager. More...
 
std::string HelpMessageGroup (const std::string &message)
 Format a string to be used as group of options in help messages. More...
 
std::string HelpMessageOpt (const std::string &option, const std::string &message)
 Format a string to be used as option description in help messages. More...
 

Variables

const char *const BITCOIN_CONF_FILENAME
 
const char *const BITCOIN_SETTINGS_FILENAME
 
ArgsManager gArgs
 

Enumeration Type Documentation

◆ OptionsCategory

enum OptionsCategory
strong
Enumerator
OPTIONS 
CONNECTION 
WALLET 
WALLET_DEBUG_TEST 
ZMQ 
DEBUG_TEST 
CHAINPARAMS 
NODE_RELAY 
BLOCK_CREATION 
RPC 
GUI 
COMMANDS 
REGISTER_COMMANDS 
AVALANCHE 
CHRONIK 
HIDDEN 

Definition at line 55 of file args.h.

Function Documentation

◆ AbsPathForConfigVal()

fs::path AbsPathForConfigVal ( const ArgsManager args,
const fs::path path,
bool  net_specific = true 
)

Most paths passed as configuration arguments are treated as relative to the datadir if they are not absolute.

Parameters
argsParsed arguments and settings.
pathThe path to be conditionally prefixed with datadir.
net_specificUse network specific datadir variant
Returns
The normalized path.

Definition at line 234 of file configfile.cpp.

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

◆ CheckDataDirOption()

bool CheckDataDirOption ( const ArgsManager args)

Definition at line 784 of file args.cpp.

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

◆ CheckValid()

bool CheckValid ( const std::string &  key,
const util::SettingsValue val,
unsigned int  flags,
std::string &  error 
)

Check settings value validity according to flags.

TODO: Add more meaningful error checks here in the future See "here's how the flags are meant to behave" in https://github.com/bitcoin/bitcoin/pull/16097#issuecomment-514627823

Definition at line 117 of file args.cpp.

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

◆ GetConfigFile()

fs::path GetConfigFile ( const ArgsManager args,
const fs::path configuration_file_path 
)

Definition at line 29 of file configfile.cpp.

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

◆ HelpMessageGroup()

std::string HelpMessageGroup ( const std::string &  message)

Format a string to be used as group of options in help messages.

Parameters
messageGroup name (e.g. "RPC server options:")
Returns
the formatted string

Definition at line 747 of file args.cpp.

Here is the caller graph for this function:

◆ HelpMessageOpt()

std::string HelpMessageOpt ( const std::string &  option,
const std::string &  message 
)

Format a string to be used as option description in help messages.

Parameters
optionOption message (e.g. "-rpcuser=<user>")
messageOption description (e.g. "Username for JSON-RPC connections")
Returns
the formatted string

Definition at line 751 of file args.cpp.

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

◆ HelpRequested()

bool HelpRequested ( const ArgsManager args)
Returns
true if help has been requested via a command-line arg

Definition at line 732 of file args.cpp.

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

◆ InterpretOption()

util::SettingsValue InterpretOption ( std::string &  section,
std::string &  key,
const std::string &  value 
)

Interpret -nofoo as if the user supplied -foo=0.

This method also tracks when the -no form was supplied, and if so, checks whether there was a double-negative (-nofoo=0 -> -foo=1).

If there was not a double negative, it removes the "no" from the key and returns false.

If there was a double negative, it removes "no" from the key, and returns true.

If there was no "no", it returns the string value untouched.

Where an option was negated can be later checked using the IsArgNegated() method. One use case for this is to have a way to disable options that are not normally boolean (e.g. using -nodebuglogfile to request that debug log output is not sent to any file at all).

Definition at line 87 of file args.cpp.

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

◆ IsSwitchChar()

bool IsSwitchChar ( char  c)
inline

Definition at line 47 of file args.h.

Here is the caller graph for this function:

◆ ParseKeyValue()

bool ParseKeyValue ( std::string &  key,
std::string &  val 
)

Definition at line 177 of file args.cpp.

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

◆ SettingToBool() [1/2]

std::optional<bool> SettingToBool ( const util::SettingsValue value)

Definition at line 565 of file args.cpp.

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

◆ SettingToBool() [2/2]

bool SettingToBool ( const util::SettingsValue value,
bool  fDefault 
)

Definition at line 575 of file args.cpp.

Here is the call graph for this function:

◆ SettingToInt() [1/2]

std::optional<int64_t> SettingToInt ( const util::SettingsValue value)

Definition at line 536 of file args.cpp.

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

◆ SettingToInt() [2/2]

int64_t SettingToInt ( const util::SettingsValue value,
int64_t  nDefault 
)

Definition at line 552 of file args.cpp.

Here is the call graph for this function:

◆ SettingToString() [1/2]

std::optional<std::string> SettingToString ( const util::SettingsValue value)

Definition at line 505 of file args.cpp.

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

◆ SettingToString() [2/2]

std::string SettingToString ( const util::SettingsValue value,
const std::string &  strDefault 
)

Definition at line 521 of file args.cpp.

Here is the call graph for this function:

◆ SetupHelpOptions()

void SetupHelpOptions ( ArgsManager args)

Add help options to the args manager.

Definition at line 737 of file args.cpp.

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

Variable Documentation

◆ BITCOIN_CONF_FILENAME

const char* const BITCOIN_CONF_FILENAME
extern

Definition at line 35 of file args.cpp.

◆ BITCOIN_SETTINGS_FILENAME

const char* const BITCOIN_SETTINGS_FILENAME
extern

Definition at line 36 of file args.cpp.

◆ gArgs

ArgsManager gArgs
extern

Definition at line 38 of file args.cpp.