/* */ #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 Pref; class OptionParser { private: std::vector > handlers_; // Index of handler in handlers_ for option who has short option name. std::vector shortOpts_; 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* argv[]) const; void parse(Option& option, std::istream& ios) const; void parseDefaultValues(Option& option) const; void setOptionHandlers (const std::vector >& handlers); void addOptionHandler(const SharedHandle& handler); // 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. const SharedHandle& find(const Pref* pref) const; // Hidden options are not returned. const SharedHandle& findById(size_t id) const; // Hidden options are not returned. const SharedHandle& findByShortName(char shortName) const; static const SharedHandle& getInstance(); }; } // namespace aria2 #endif // D_OPTION_PARSER_H