diff options
Diffstat (limited to 'src/OptionHandlerImpl.cc')
| -rw-r--r-- | src/OptionHandlerImpl.cc | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc index 600564cb..6dec8503 100644 --- a/src/OptionHandlerImpl.cc +++ b/src/OptionHandlerImpl.cc @@ -587,15 +587,18 @@ std::string PrioritizePieceOptionHandler::createPossibleValuesString() const return "head[=SIZE], tail[=SIZE]"; } -OptimizeConcurrentDownloadsOptionHandler::OptimizeConcurrentDownloadsOptionHandler( - PrefPtr pref, const char* description, const std::string& defaultValue, char shortName) +OptimizeConcurrentDownloadsOptionHandler:: + OptimizeConcurrentDownloadsOptionHandler(PrefPtr pref, + const char* description, + const std::string& defaultValue, + char shortName) : AbstractOptionHandler(pref, description, defaultValue, OptionHandler::OPT_ARG, shortName) { } -void OptimizeConcurrentDownloadsOptionHandler::parseArg(Option& option, - const std::string& optarg) const +void OptimizeConcurrentDownloadsOptionHandler::parseArg( + Option& option, const std::string& optarg) const { if (optarg == "true" || optarg.empty()) { option.put(pref_, A2_V_TRUE); @@ -606,28 +609,29 @@ void OptimizeConcurrentDownloadsOptionHandler::parseArg(Option& option, else { auto p = util::divide(std::begin(optarg), std::end(optarg), ':'); - std::string coeff_b(p.second.first,p.second.second); - if(coeff_b.empty()) { + std::string coeff_b(p.second.first, p.second.second); + if (coeff_b.empty()) { std::string msg = pref_->k; msg += " "; - msg += _("must be either 'true', 'false' or a pair numeric coefficients A and B under the form 'A:B'."); + msg += _("must be either 'true', 'false' or a pair numeric coefficients " + "A and B under the form 'A:B'."); throw DL_ABORT_EX(msg); } - std::string coeff_a(p.first.first,p.first.second); + std::string coeff_a(p.first.first, p.first.second); - - PrefPtr pref=PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA; - std::string *sptr = &coeff_a; - for(;;) { + PrefPtr pref = PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA; + std::string* sptr = &coeff_a; + for (;;) { try { double dbl = std::stod(*sptr); - } catch(std::invalid_argument & ex) { + } + catch (std::invalid_argument& ex) { throw DL_ABORT_EX(fmt("Bad number '%s'", sptr->c_str())); } - option.put(pref,*sptr); + option.put(pref, *sptr); - if(pref == PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFB) { + if (pref == PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFB) { break; } pref = PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFB; @@ -637,7 +641,8 @@ void OptimizeConcurrentDownloadsOptionHandler::parseArg(Option& option, } } -std::string OptimizeConcurrentDownloadsOptionHandler::createPossibleValuesString() const +std::string +OptimizeConcurrentDownloadsOptionHandler::createPossibleValuesString() const { return "true, false, A:B"; } |
