/* */ #ifndef _D_OPTION_PARSER_H_ #define _D_OPTION_PARSER_H_ #include "common.h" #include #include #include #include "SharedHandle.h" namespace aria2 { class Option; class OptionHandler; class OptionParser { private: int idCounter_; // optionHandlers_ is sorted by OptionHandler::getName() in // ascending order. std::vector > optionHandlers_; SharedHandle getOptionHandlerByName(const std::string& optName); static SharedHandle optionParser_; public: OptionParser(); ~OptionParser() {} // Parses options in argv and writes option name and value to out in // NAME=VALUE format. Non-option strings are stored in nonopts. // Throws Exception when an unrecognized option is found. void parseArg(std::ostream& out, std::vector& nonopts, int argc, char* const argv[]); void parse(Option& option, std::istream& ios); void parseDefaultValues(Option& option) const; void setOptionHandlers (const std::vector >& optionHandlers); void addOptionHandler(const SharedHandle& optionHandler); // Hidden options are not returned. std::vector > findByTag(const std::string& tag) const; // Hidden options are not returned. std::vector > findByNameSubstring(const std::string& substring) const; // Hidden options are not returned. std::vector > findAll() const; // Hidden options are not returned. SharedHandle findByName(const std::string& name) const; // Hidden options are not returned. SharedHandle findByID(int id) const; // Hidden options are not returned. SharedHandle findByShortName(char shortName) const; static const SharedHandle& getInstance(); }; typedef SharedHandle OptionParserHandle; } // namespace aria2 #endif // _D_OPTION_PARSER_H_