| 425 | } |
| 426 | |
| 427 | bool GetBoolArg(const std::string& strArg, bool fDefault) |
| 428 | { |
| 429 | if (mapArgs.count(strArg)) { |
| 430 | |
| 431 | int n = fDefault ? 1 : 0; |
| 432 | |
| 433 | // sample: -testnet |
| 434 | if (mapArgs[strArg].empty()) |
| 435 | return true; |
| 436 | |
| 437 | try { |
| 438 | // stoi() doesn't handle boolean strings |
| 439 | if (mapArgs[strArg] == "false") |
| 440 | n = 0; |
| 441 | else if (mapArgs[strArg] == "true") |
| 442 | n = 1; |
| 443 | else |
| 444 | n = std::stoi(mapArgs[strArg]); |
| 445 | } catch (const std::exception& e) { |
| 446 | } |
| 447 | return (n != 0); |
| 448 | } |
| 449 | return fDefault; |
| 450 | } |
| 451 | |
| 452 | bool SoftSetArg(const std::string& strArg, const std::string& strValue) |
| 453 | { |