cmdline_parser.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef CMDLINE_PARSER_HPP_INCLUDED
  2. #define CMDLINE_PARSER_HPP_INCLUDED
  3. #include <string>
  4. struct cmdlineParserCtl;
  5. class CmdlineParser {
  6. public:
  7. CmdlineParser();
  8. ~CmdlineParser();
  9. enum optType {FLAG, INT, UINT, STRING, BINUINT, FLOAT};
  10. void
  11. defineOption(std::string const optionName,
  12. optType const optionType);
  13. void
  14. processOptions(int const argc,
  15. const char ** const argv);
  16. bool
  17. optionIsPresent(std::string const optionName) const;
  18. int
  19. getOptionValueInt(std::string const optionName) const;
  20. unsigned int
  21. getOptionValueUint(std::string const optionName) const;
  22. std::string
  23. getOptionValueString(std::string const optionName) const;
  24. unsigned long long
  25. getOptionValueBinUint(std::string const optionName) const;
  26. double
  27. getOptionValueFloat(std::string const optionName) const;
  28. unsigned int
  29. argumentCount() const;
  30. std::string
  31. getArgument(unsigned int const argNumber) const;
  32. private:
  33. struct cmdlineParserCtl * cp;
  34. // Make sure no one can copy this object, because if there are two
  35. // copies, there will be two attempts to destroy *cp.
  36. CmdlineParser(CmdlineParser const&) {};
  37. CmdlineParser&
  38. operator=(CmdlineParser const&) {return *this;}
  39. };
  40. #endif