From 3832ed97c616eff0057d7a0e5a161c4282537160 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 21 Oct 2011 21:56:42 +0900 Subject: Rewritten Option. Introduced Pref. Now preference key is Pref instead of just string. It has Option ID. Now option lookup and setting takes O(1) using Pref object. --- src/OptionHandlerException.cc | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/OptionHandlerException.cc') diff --git a/src/OptionHandlerException.cc b/src/OptionHandlerException.cc index f3949768..04507f65 100644 --- a/src/OptionHandlerException.cc +++ b/src/OptionHandlerException.cc @@ -34,31 +34,38 @@ /* copyright --> */ #include "OptionHandlerException.h" #include "fmt.h" +#include "prefs.h" namespace aria2 { const std::string OptionHandlerException::MESSAGE ("We encountered a problem while processing the option '--%s'."); -OptionHandlerException::OptionHandlerException(const char* file, int line, - const std::string& optName): - RecoverableException - (file, line, fmt(MESSAGE.c_str(), optName.c_str()), error_code::OPTION_ERROR), - optName_(optName) {} +OptionHandlerException::OptionHandlerException +(const char* file, int line, + const Pref* pref) + : RecoverableException + (file, line, fmt(MESSAGE.c_str(), pref->k.c_str()), + error_code::OPTION_ERROR), + pref_(pref) +{} -OptionHandlerException::OptionHandlerException(const char* file, int line, - const std::string& optName, - const Exception& cause): - RecoverableException - (file, line, fmt(MESSAGE.c_str(), optName.c_str()), error_code::OPTION_ERROR, - cause), - optName_(optName) {} +OptionHandlerException::OptionHandlerException +(const char* file, int line, + const Pref* pref, + const Exception& cause) + : RecoverableException + (file, line, fmt(MESSAGE.c_str(), pref->k.c_str()), + error_code::OPTION_ERROR, + cause), + pref_(pref) +{} OptionHandlerException::~OptionHandlerException() throw() {} const std::string& OptionHandlerException::getOptionName() const throw() { - return optName_; + return pref_->k; } SharedHandle OptionHandlerException::copy() const -- cgit