/* */ #include "OptionParser.h" #include "Util.h" #include "OptionHandlerImpl.h" #include "Option.h" #include "A2STR.h" #include #include namespace aria2 { void OptionParser::parse(Option* option, std::istream& is) { std::string line; int32_t linenum = 0; while(getline(is, line)) { ++linenum; if(Util::startsWith(line, A2STR::SHARP_C)) { continue; } std::pair nv = Util::split(line, A2STR::EQUAL_C); OptionHandlerHandle handler = getOptionHandlerByName(nv.first); handler->parse(option, nv.second); } } OptionHandlerHandle OptionParser::getOptionHandlerByName(const std::string& optName) { for(OptionHandlers::iterator itr = _optionHandlers.begin(); itr != _optionHandlers.end(); ++itr) { if((*itr)->canHandle(optName)) { return *itr; } } return SharedHandle(new NullOptionHandler()); } void OptionParser::setOptionHandlers(const std::deque >& optionHandlers) { _optionHandlers = optionHandlers; } } // namespace aria2