MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ParseParameters

Method ParseParameters

src/util.cpp:414–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::string& error)
415{
416 LOCK(cs_args);
417 m_override_args.clear();
418
419 for (int i = 1; i < argc; i++) {
420 std::string key(argv[i]);
421 std::string val;
422 size_t is_index = key.find('=');
423 if (is_index != std::string::npos) {
424 val = key.substr(is_index + 1);
425 key.erase(is_index);
426 }
427#ifdef WIN32
428 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
429 if (key[0] == '/')
430 key[0] = '-';
431#endif
432
433 if (key[0] != '-')
434 break;
435
436 // Transform --foo to -foo
437 if (key.length() > 1 && key[1] == '-')
438 key.erase(0, 1);
439
440 // Check for -nofoo
441 if (InterpretNegatedOption(key, val)) {
442 m_override_args[key].clear();
443 } else {
444 m_override_args[key].push_back(val);
445 }
446
447 // Check that the arg is known
448 if (!(IsSwitchChar(key[0]) && key.size() == 1)) {
449 if (!IsArgKnown(key)) {
450 error = strprintf("Invalid parameter %s", key.c_str());
451 return false;
452 }
453 }
454 }
455
456 // we do not allow -includeconf from command line, so we clear it here
457 auto it = m_override_args.find("-includeconf");
458 if (it != m_override_args.end()) {
459 if (it->second.size() > 0) {
460 for (const auto& ic : it->second) {
461 error += "-includeconf cannot be used from commandline; -includeconf=" + ic + "\n";
462 }
463 return false;
464 }
465 }
466 return true;
467}
468
469bool ArgsManager::IsArgKnown(const std::string& key) const
470{

Callers 7

AppInitRawTxFunction · 0.80
AppInitRPCFunction · 0.80
AppInitFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
ResetArgsFunction · 0.80
parseParametersMethod · 0.80
mainFunction · 0.80

Calls 9

InterpretNegatedOptionFunction · 0.85
IsSwitchCharFunction · 0.85
clearMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
ResetArgsFunction · 0.64