MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / AddArg

Method AddArg

src/common/args.cpp:659–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659void ArgsManager::AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat)
660{
661 Assert((flags & ArgsManager::COMMAND) == 0); // use AddCommand
662
663 // Split arg name from its help param
664 size_t eq_index = name.find('=');
665 if (eq_index == std::string::npos) {
666 eq_index = name.size();
667 }
668 std::string arg_name = name.substr(0, eq_index);
669
670 LOCK(cs_args);
671
672 // Allow duplicates involving HIDDEN — it is used as a placeholder for args
673 // unavailable in this binary but tolerated for shared config files (see #13441).
674 for (const auto& arg_map : m_available_args) {
675 if (arg_map.first == OptionsCategory::HIDDEN || cat == OptionsCategory::HIDDEN) continue;
676 Assert(!arg_map.second.contains(arg_name));
677 }
678
679 std::map<std::string, Arg>& arg_map = m_available_args[cat];
680 auto ret = arg_map.emplace(arg_name, Arg{name.substr(eq_index, name.size() - eq_index), help, flags});
681 assert(ret.second); // Make sure an insertion actually happened
682
683 if (flags & ArgsManager::NETWORK_ONLY) {
684 m_network_only_args.emplace(arg_name);
685 }
686}
687
688void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)
689{

Callers 15

SetupBitcoinTxArgsFunction · 0.80
SetupCliArgsFunction · 0.80
SetupBitcoinUtilArgsFunction · 0.80
SetupServerArgsFunction · 0.80
SetupWalletToolArgsFunction · 0.80
AddLoggingArgsFunction · 0.80
AddWalletOptionsMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
SetupArgsFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls 4

findMethod · 0.80
emplaceMethod · 0.80
sizeMethod · 0.45
containsMethod · 0.45

Tested by 5

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64
SetupArgsFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64
SetupCommonTestArgsFunction · 0.64