mirror of https://github.com/aria2/aria2
Implement DownloadResultDH::getOption()/getOptions()
parent
dc8ed34cb0
commit
e4bf9b9cc5
|
@ -661,6 +661,29 @@ void pushRequestOption
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const std::string& getRequestOption(const SharedHandle<Option>& option,
|
||||||
|
const std::string& name)
|
||||||
|
{
|
||||||
|
const Pref* pref = option::k2p(name);
|
||||||
|
if(OptionParser::getInstance()->find(pref)) {
|
||||||
|
return option->get(pref);
|
||||||
|
} else {
|
||||||
|
return A2STR::NIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
KeyVals getRequestOptions(const SharedHandle<Option>& option)
|
||||||
|
{
|
||||||
|
KeyVals res;
|
||||||
|
pushRequestOption(std::back_inserter(res), option,
|
||||||
|
OptionParser::getInstance());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct RequestGroupDH : public DownloadHandle {
|
struct RequestGroupDH : public DownloadHandle {
|
||||||
RequestGroupDH(const SharedHandle<RequestGroup>& group)
|
RequestGroupDH(const SharedHandle<RequestGroup>& group)
|
||||||
|
@ -800,19 +823,11 @@ struct RequestGroupDH : public DownloadHandle {
|
||||||
}
|
}
|
||||||
virtual const std::string& getOption(const std::string& name)
|
virtual const std::string& getOption(const std::string& name)
|
||||||
{
|
{
|
||||||
const Pref* pref = option::k2p(name);
|
return getRequestOption(group->getOption(), name);
|
||||||
if(OptionParser::getInstance()->find(pref)) {
|
|
||||||
return group->getOption()->get(pref);
|
|
||||||
} else {
|
|
||||||
return A2STR::NIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtual KeyVals getOptions()
|
virtual KeyVals getOptions()
|
||||||
{
|
{
|
||||||
KeyVals res;
|
return getRequestOptions(group->getOption());
|
||||||
pushRequestOption(std::back_inserter(res), group->getOption(),
|
|
||||||
OptionParser::getInstance());
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
SharedHandle<RequestGroup> group;
|
SharedHandle<RequestGroup> group;
|
||||||
TransferStat ts;
|
TransferStat ts;
|
||||||
|
@ -917,11 +932,11 @@ struct DownloadResultDH : public DownloadHandle {
|
||||||
}
|
}
|
||||||
virtual const std::string& getOption(const std::string& name)
|
virtual const std::string& getOption(const std::string& name)
|
||||||
{
|
{
|
||||||
return A2STR::NIL;
|
return getRequestOption(dr->option, name);
|
||||||
}
|
}
|
||||||
virtual KeyVals getOptions()
|
virtual KeyVals getOptions()
|
||||||
{
|
{
|
||||||
return KeyVals();
|
return getRequestOptions(dr->option);
|
||||||
}
|
}
|
||||||
SharedHandle<DownloadResult> dr;
|
SharedHandle<DownloadResult> dr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -867,10 +867,6 @@ public:
|
||||||
* not return options which have no default value and have not been
|
* not return options which have no default value and have not been
|
||||||
* set by :func:`sessionNew()`, configuration files or API
|
* set by :func:`sessionNew()`, configuration files or API
|
||||||
* functions.
|
* functions.
|
||||||
*
|
|
||||||
* Calling this function for the download which is not in
|
|
||||||
* :c:macro:`DOWNLOAD_ACTIVE`, :c:macro:`DOWNLOAD_PAUSED` or
|
|
||||||
* :c:macro:`DOWNLOAD_WAITING` will return empty array.
|
|
||||||
*/
|
*/
|
||||||
virtual KeyVals getOptions() = 0;
|
virtual KeyVals getOptions() = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue