mirror of https://github.com/aria2/aria2
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Parse options in -i list using OptionParser. * src/UriListParser.cc * src/UriListParser.hpull/1/head
parent
c2447e3094
commit
f4da71fc6d
|
@ -1,3 +1,9 @@
|
|||
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Parse options in -i list using OptionParser.
|
||||
* src/UriListParser.cc
|
||||
* src/UriListParser.h
|
||||
|
||||
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Don't reset URI in retry to avoid additional round trips because
|
||||
|
|
|
@ -35,26 +35,33 @@
|
|||
#include "UriListParser.h"
|
||||
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
|
||||
#include "Util.h"
|
||||
#include "Option.h"
|
||||
#include "OptionHandlerFactory.h"
|
||||
#include "OptionHandler.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
UriListParser::UriListParser(std::istream& in):_in(in) {}
|
||||
UriListParser::UriListParser(std::istream& in):_in(in)
|
||||
{
|
||||
_optparser.setOptionHandlers(OptionHandlerFactory::createOptionHandlers());
|
||||
}
|
||||
|
||||
UriListParser::~UriListParser() {}
|
||||
|
||||
static void getOptions(Option& op, std::string& line, std::istream& in)
|
||||
void UriListParser::getOptions(Option& op)
|
||||
{
|
||||
while(getline(in, line)) {
|
||||
if(Util::startsWith(line, " ")) {
|
||||
std::pair<std::string, std::string> p = Util::split(line, "=");
|
||||
op.put(p.first, p.second);
|
||||
std::stringstream ss;
|
||||
while(getline(_in, _line)) {
|
||||
if(Util::startsWith(_line, " ")) {
|
||||
ss << _line << "\n";
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_optparser.parse(op, ss);
|
||||
}
|
||||
|
||||
void UriListParser::parseNext(std::deque<std::string>& uris, Option& op)
|
||||
|
@ -68,7 +75,7 @@ void UriListParser::parseNext(std::deque<std::string>& uris, Option& op)
|
|||
do {
|
||||
if(!Util::trim(_line).empty()) {
|
||||
Util::slice(uris, _line, '\t', true);
|
||||
getOptions(op, _line, _in);
|
||||
getOptions(op);
|
||||
return;
|
||||
}
|
||||
} while(getline(_in, _line));
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <iosfwd>
|
||||
|
||||
#include "Option.h"
|
||||
#include "OptionParser.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -49,7 +50,11 @@ class UriListParser {
|
|||
private:
|
||||
std::istream& _in;
|
||||
|
||||
OptionParser _optparser;
|
||||
|
||||
std::string _line;
|
||||
|
||||
void getOptions(Option& op);
|
||||
public:
|
||||
UriListParser(std::istream& in);
|
||||
|
||||
|
|
Loading…
Reference in New Issue