You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
1.4 KiB

  1. #pragma once
  2. #include <string>
  3. #include <cppargs/misc/context.h>
  4. namespace cppargs
  5. {
  6. /**
  7. * @brief Class to store all meta data for a option.
  8. */
  9. struct option_meta
  10. {
  11. const std::string long_name { "" }; //!< long name of the option (without the prepending --)
  12. const char short_name { '\0' }; //!< short option of the option (without the prependding -)
  13. const std::string description { "" }; //!< description for this option
  14. const std::string default_value { "" }; //!< default value for this option
  15. const bool optional { true }; //!< TRUE if this option is optional, FALSE otherwise
  16. };
  17. /**
  18. * @brief Option to parse from command line arguments
  19. */
  20. struct option
  21. {
  22. public:
  23. const option_meta meta; //!< meta data of the option
  24. protected:
  25. /**
  26. * @brief Constructor.
  27. *
  28. * @param[in] p_long_name Long name of the option.
  29. * @param[in] p_short_name Short name of the option.
  30. */
  31. inline option(const option_meta& meta);
  32. public:
  33. /**
  34. * @brief Destructor.
  35. */
  36. virtual ~option() = default;
  37. /**
  38. * @brief Parse the option using the current context.
  39. *
  40. * @param[in|out] c Context to use for parsing.
  41. */
  42. virtual void parse(context& c) const = 0;
  43. };
  44. }