/** * @file argparser.h * @brief Declaration of the argument parser class. * @author Andreas Aardal Hanssen * @date 2002-2005 */ #ifndef ARGPARSER_H_INCLUDED #define ARGPARSER_H_INCLUDED #include #include #include namespace Binc { struct ArgOpts { std::string c; bool b; bool o; std::string desc; }; class CommandLineArgs { public: CommandLineArgs(); bool parse(int argc, char *argv[]); std::string errorString() const; int argc() const; const std::string operator[](const std::string &arg) const; void addOptional(const std::string &arg, const std::string &desc, bool boolean); void addRequired(const std::string &arg, const std::string &desc, bool boolean); bool hasArg(const std::string &arg) const; std::string usageString() const; void setTail(const std::string &str); const std::vector &getUnqualifiedArgs() const; private: void registerArg(const std::string &arg, const std::string &desc, bool boolean, bool optional); std::string errString; std::map reg; std::map args; std::map passedArgs; std::vector unqualified; std::string tail; std::string head; int ac; }; } #endif