mirror of https://github.com/aria2/aria2
Removed OptionHandler::{get,set}OptionID() and canHandle().
Removed typedefs in OptionHandler and NameMatchOptionHandler.pull/2/head
parent
1872aef953
commit
3d767543e6
|
@ -52,7 +52,6 @@ NameMatchOptionHandler::NameMatchOptionHandler
|
|||
: pref_(pref),
|
||||
description_(description),
|
||||
defaultValue_(defaultValue),
|
||||
id_(0),
|
||||
argType_(argType),
|
||||
shortName_(shortName),
|
||||
hidden_(false),
|
||||
|
@ -65,11 +64,6 @@ NameMatchOptionHandler::NameMatchOptionHandler
|
|||
|
||||
NameMatchOptionHandler::~NameMatchOptionHandler() {}
|
||||
|
||||
bool NameMatchOptionHandler::canHandle(const std::string& optName)
|
||||
{
|
||||
return pref_->k == optName;
|
||||
}
|
||||
|
||||
void NameMatchOptionHandler::parse(Option& option, const std::string& arg)
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -56,8 +56,6 @@ protected:
|
|||
|
||||
std::vector<std::string> tags_;
|
||||
|
||||
int id_;
|
||||
|
||||
OptionHandler::ARG_TYPE argType_;
|
||||
|
||||
char shortName_;
|
||||
|
@ -81,8 +79,6 @@ public:
|
|||
|
||||
virtual ~NameMatchOptionHandler();
|
||||
|
||||
virtual bool canHandle(const std::string& optName);
|
||||
|
||||
virtual void parse(Option& option, const std::string& arg);
|
||||
|
||||
virtual bool hasTag(const std::string& tag) const;
|
||||
|
@ -123,16 +119,6 @@ public:
|
|||
return shortName_;
|
||||
}
|
||||
|
||||
virtual int getOptionID() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
virtual void setOptionID(int id)
|
||||
{
|
||||
id_ = id;
|
||||
}
|
||||
|
||||
virtual OptionHandler::ARG_TYPE getArgType() const
|
||||
{
|
||||
return argType_;
|
||||
|
@ -189,8 +175,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef SharedHandle<NameMatchOptionHandler> NameMatchOptionHandlerHandle;
|
||||
|
||||
} // namespace aria2
|
||||
|
||||
#endif // D_NAME_MATCH_OPTION_HANDLER_H
|
||||
|
|
|
@ -62,7 +62,6 @@ class OptionHandler {
|
|||
public:
|
||||
virtual ~OptionHandler() {}
|
||||
|
||||
virtual bool canHandle(const std::string& optName) = 0;
|
||||
virtual void parse(Option& option, const std::string& arg) = 0;
|
||||
|
||||
virtual std::string createPossibleValuesString() const = 0;
|
||||
|
@ -95,10 +94,6 @@ public:
|
|||
|
||||
virtual char getShortName() const = 0;
|
||||
|
||||
virtual int getOptionID() const = 0;
|
||||
|
||||
virtual void setOptionID(int id) = 0;
|
||||
|
||||
// Returns true if option value should be erased from argv to
|
||||
// prevent it from appearing in the output of ps.
|
||||
virtual bool getEraseAfterParse() const = 0;
|
||||
|
@ -115,31 +110,6 @@ public:
|
|||
virtual void setCumulative(bool f) = 0;
|
||||
};
|
||||
|
||||
class OptionHandlerNameLesser:public std::binary_function
|
||||
<SharedHandle<OptionHandler>, SharedHandle<OptionHandler>, bool> {
|
||||
public:
|
||||
bool operator()
|
||||
(const SharedHandle<OptionHandler>& lhs,
|
||||
const SharedHandle<OptionHandler>& rhs) const
|
||||
{
|
||||
return lhs->getName() < rhs->getName();
|
||||
}
|
||||
};
|
||||
|
||||
class OptionHandlerIDLesser:public std::binary_function
|
||||
<SharedHandle<OptionHandler>, SharedHandle<OptionHandler>, bool> {
|
||||
public:
|
||||
bool operator()
|
||||
(const SharedHandle<OptionHandler>& lhs,
|
||||
const SharedHandle<OptionHandler>& rhs) const
|
||||
{
|
||||
return lhs->getOptionID() < rhs->getOptionID();
|
||||
}
|
||||
};
|
||||
|
||||
typedef SharedHandle<OptionHandler> OptionHandlerHandle;
|
||||
typedef std::vector<OptionHandlerHandle> OptionHandlers;
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, const OptionHandler& optionHandler);
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -45,9 +45,10 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||
std::vector<SharedHandle<OptionHandler> >
|
||||
OptionHandlerFactory::createOptionHandlers()
|
||||
{
|
||||
OptionHandlers handlers;
|
||||
std::vector<SharedHandle<OptionHandler> > handlers;
|
||||
// General Options
|
||||
{
|
||||
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||
|
|
|
@ -702,11 +702,6 @@ DeprecatedOptionHandler::DeprecatedOptionHandler
|
|||
: depOptHandler_(depOptHandler), repOptHandler_(repOptHandler)
|
||||
{}
|
||||
|
||||
bool DeprecatedOptionHandler::canHandle(const std::string& optName)
|
||||
{
|
||||
return depOptHandler_->canHandle(optName);
|
||||
}
|
||||
|
||||
void DeprecatedOptionHandler::parse(Option& option, const std::string& arg)
|
||||
{
|
||||
if(repOptHandler_) {
|
||||
|
@ -780,16 +775,6 @@ char DeprecatedOptionHandler::getShortName() const
|
|||
return depOptHandler_->getShortName();
|
||||
}
|
||||
|
||||
int DeprecatedOptionHandler::getOptionID() const
|
||||
{
|
||||
return depOptHandler_->getOptionID();
|
||||
}
|
||||
|
||||
void DeprecatedOptionHandler::setOptionID(int id)
|
||||
{
|
||||
depOptHandler_->setOptionID(id);
|
||||
}
|
||||
|
||||
bool DeprecatedOptionHandler::getEraseAfterParse() const
|
||||
{
|
||||
return depOptHandler_->getEraseAfterParse();
|
||||
|
|
|
@ -294,7 +294,6 @@ public:
|
|||
(const SharedHandle<OptionHandler>& depOptHandler,
|
||||
const SharedHandle<OptionHandler>& repOptHandler =
|
||||
SharedHandle<OptionHandler>());
|
||||
virtual bool canHandle(const std::string& optName);
|
||||
virtual void parse(Option& option, const std::string& arg);
|
||||
virtual std::string createPossibleValuesString() const;
|
||||
virtual bool hasTag(const std::string& tag) const;
|
||||
|
@ -308,8 +307,6 @@ public:
|
|||
virtual const Pref* getPref() const;
|
||||
virtual ARG_TYPE getArgType() const;
|
||||
virtual char getShortName() const;
|
||||
virtual int getOptionID() const;
|
||||
virtual void setOptionID(int id);
|
||||
virtual bool getEraseAfterParse() const;
|
||||
virtual void setEraseAfterParse(bool eraseAfterParse);
|
||||
virtual bool getInitialOption() const;
|
||||
|
|
|
@ -58,8 +58,6 @@ CPPUNIT_TEST_SUITE_REGISTRATION( OptionHandlerTest );
|
|||
void OptionHandlerTest::testBooleanOptionHandler()
|
||||
{
|
||||
BooleanOptionHandler handler(PREF_DAEMON);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_DAEMON->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle(PREF_DIR->k));
|
||||
Option option;
|
||||
handler.parse(option, A2_V_TRUE);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(A2_V_TRUE), option.get(PREF_DAEMON));
|
||||
|
@ -76,8 +74,6 @@ void OptionHandlerTest::testBooleanOptionHandler()
|
|||
void OptionHandlerTest::testNumberOptionHandler()
|
||||
{
|
||||
NumberOptionHandler handler(PREF_TIMEOUT);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle(PREF_DIR->k));
|
||||
Option option;
|
||||
handler.parse(option, "0");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("0"), option.get(PREF_TIMEOUT));
|
||||
|
@ -136,8 +132,6 @@ void OptionHandlerTest::testNumberOptionHandler_min_max()
|
|||
void OptionHandlerTest::testUnitNumberOptionHandler()
|
||||
{
|
||||
UnitNumberOptionHandler handler(PREF_TIMEOUT);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "4294967296");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("4294967296"), option.get(PREF_TIMEOUT));
|
||||
|
@ -161,8 +155,6 @@ void OptionHandlerTest::testUnitNumberOptionHandler()
|
|||
void OptionHandlerTest::testParameterOptionHandler_1argInit()
|
||||
{
|
||||
ParameterOptionHandler handler(PREF_TIMEOUT, "", "", "value1");
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "value1");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get(PREF_TIMEOUT));
|
||||
|
@ -177,8 +169,6 @@ void OptionHandlerTest::testParameterOptionHandler_1argInit()
|
|||
void OptionHandlerTest::testParameterOptionHandler_2argsInit()
|
||||
{
|
||||
ParameterOptionHandler handler(PREF_TIMEOUT, "", "", "value1", "value2");
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "value1");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get(PREF_TIMEOUT));
|
||||
|
@ -199,8 +189,6 @@ void OptionHandlerTest::testParameterOptionHandler_listInit()
|
|||
validValues.push_back("value2");
|
||||
|
||||
ParameterOptionHandler handler(PREF_TIMEOUT, "", "", validValues);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "value1");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get(PREF_TIMEOUT));
|
||||
|
@ -217,8 +205,6 @@ void OptionHandlerTest::testParameterOptionHandler_listInit()
|
|||
void OptionHandlerTest::testDefaultOptionHandler()
|
||||
{
|
||||
DefaultOptionHandler handler(PREF_TIMEOUT);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "bar");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("bar"), option.get(PREF_TIMEOUT));
|
||||
|
@ -238,8 +224,6 @@ void OptionHandlerTest::testDefaultOptionHandler()
|
|||
void OptionHandlerTest::testFloatNumberOptionHandler()
|
||||
{
|
||||
FloatNumberOptionHandler handler(PREF_TIMEOUT);
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_TIMEOUT->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "1.0");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("1.0"), option.get(PREF_TIMEOUT));
|
||||
|
@ -298,8 +282,6 @@ void OptionHandlerTest::testFloatNumberOptionHandler_min_max()
|
|||
void OptionHandlerTest::testHttpProxyOptionHandler()
|
||||
{
|
||||
HttpProxyOptionHandler handler(PREF_HTTP_PROXY, "", "");
|
||||
CPPUNIT_ASSERT(handler.canHandle(PREF_HTTP_PROXY->k));
|
||||
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
||||
Option option;
|
||||
handler.parse(option, "proxy:65535");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://proxy:65535/"),
|
||||
|
|
Loading…
Reference in New Issue