/* */ #ifndef D_OPTION_PARSER_H #define D_OPTION_PARSER_H #include "common.h" #include #include #include #include #include #include "prefs.h" namespace aria2 { class Option; class OptionHandler; class OptionParser { private: std::vector handlers_; // Index of handler in handlers_ for option who has short option name. std::vector shortOpts_; static std::shared_ptr 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 parse(Option& option, const KeyVals& options) const; void parseDefaultValues(Option& option) const; void setOptionHandlers (const std::vector& handlers); void addOptionHandler(OptionHandler* handler); // Hidden options are not returned. std::vector findByTag(uint32_t 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 OptionHandler* find(PrefPtr pref) const; // Hidden options are not returned. const OptionHandler* findById(size_t id) const; // Hidden options are not returned. const OptionHandler* findByShortName(char shortName) const; static const std::shared_ptr& getInstance(); // Deletes statically allocated instace. Call this at the end of the // program. static void deleteInstance(); }; } // namespace aria2 #endif // D_OPTION_PARSER_H