#ifndef OPTS_H #define OPTS_H #include #include #include #include #include // Define a class to hold the options and parse arguments class OptionParser { public: OptionParser() : verbose(false), printUsage(false), traceCallables(false) {} ~OptionParser() = default; void parseArguments(int argc, char *argv[], char **envp); std::string stringifyOptions(void) const; std::string getUsage() const; static OptionParser &getOptions(void) { static OptionParser options; return options; } public: class Exception : public std::exception { public: Exception() = default; ~Exception() override = default; const char* what() const noexcept override = 0; }; std::string argv0; std::vector senseApiLibPath; std::vector senseApiLibs; std::string dapSpecs; std::vector dapSpecFiles; bool verbose, printUsage, traceCallables; static struct option longOptions[]; }; class OptionsParserError : public std::invalid_argument, public OptionParser::Exception { public: OptionsParserError( const std::string& errorMessage, const OptionParser& parser); const char* what() const noexcept override; }; class JustPrintUsageNoError : public OptionParser::Exception { public: explicit JustPrintUsageNoError(const OptionParser& parser); const char* what() const noexcept override; private: std::string message; }; #endif // OPTS_H