Changeset View
Changeset View
Standalone View
Standalone View
src/util.h
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
inline bool IsSwitchChar(char c) { | inline bool IsSwitchChar(char c) { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
return c == '-' || c == '/'; | return c == '-' || c == '/'; | ||||
#else | #else | ||||
return c == '-'; | return c == '-'; | ||||
#endif | #endif | ||||
} | } | ||||
enum class OptionsCategory { | |||||
OPTIONS, | |||||
CONNECTION, | |||||
WALLET, | |||||
WALLET_DEBUG_TEST, | |||||
ZMQ, | |||||
DEBUG_TEST, | |||||
CHAINPARAMS, | |||||
NODE_RELAY, | |||||
BLOCK_CREATION, | |||||
RPC, | |||||
GUI, | |||||
COMMANDS, | |||||
REGISTER_COMMANDS | |||||
}; | |||||
class ArgsManager { | class ArgsManager { | ||||
protected: | protected: | ||||
friend class ArgsManagerHelper; | friend class ArgsManagerHelper; | ||||
mutable CCriticalSection cs_args; | mutable CCriticalSection cs_args; | ||||
std::map<std::string, std::vector<std::string>> m_override_args; | std::map<std::string, std::vector<std::string>> m_override_args; | ||||
std::map<std::string, std::vector<std::string>> m_config_args; | std::map<std::string, std::vector<std::string>> m_config_args; | ||||
std::string m_network; | std::string m_network; | ||||
std::set<std::string> m_network_only_args; | std::set<std::string> m_network_only_args; | ||||
std::map<std::pair<OptionsCategory, std::string>, | |||||
std::pair<std::string, bool>> | |||||
m_available_args; | |||||
void ReadConfigStream(std::istream &stream); | void ReadConfigStream(std::istream &stream); | ||||
public: | public: | ||||
ArgsManager(); | ArgsManager(); | ||||
/** | /** | ||||
* Select the network in use | * Select the network in use | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Looks for -regtest, -testnet and returns the appropriate BIP70 chain | * Looks for -regtest, -testnet and returns the appropriate BIP70 chain | ||||
* name. | * name. | ||||
* @return CBaseChainParams::MAIN by default; raises runtime error if an | * @return CBaseChainParams::MAIN by default; raises runtime error if an | ||||
* invalid combination is given. | * invalid combination is given. | ||||
*/ | */ | ||||
std::string GetChainName() const; | std::string GetChainName() const; | ||||
/** | |||||
* Add argument | |||||
*/ | |||||
void AddArg(const std::string &name, const std::string &help, | |||||
const bool debug_only, const OptionsCategory &cat); | |||||
// Remove an arg setting, used only in testing | // Remove an arg setting, used only in testing | ||||
void ClearArg(const std::string &strArg); | void ClearArg(const std::string &strArg); | ||||
/** | |||||
* Get the help string | |||||
*/ | |||||
std::string GetHelpMessage(); | |||||
}; | }; | ||||
extern ArgsManager gArgs; | extern ArgsManager gArgs; | ||||
/** | /** | ||||
* @return true if help has been requested via a command-line arg | * @return true if help has been requested via a command-line arg | ||||
*/ | */ | ||||
bool HelpRequested(const ArgsManager &args); | bool HelpRequested(const ArgsManager &args); | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |