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.
 
 
 

35 lines
1.0 KiB

  1. #pragma once
  2. #include <string>
  3. #include <cstring>
  4. namespace cppargs
  5. {
  6. enum class next_result
  7. {
  8. finished = 0, //!< context does not have any further arguments
  9. option_short = 1, //!< moving to next argument was successfull (argument starts with - or --)
  10. option_long = 2, //!< moving to next argument was successfull (argument starts with - or --)
  11. argument = 3, //!< moving to next argument was successfull (argument does not starts with - or --)
  12. };
  13. struct context
  14. {
  15. int argc;
  16. char const * const * argv;
  17. char const * exe;
  18. char const * arg { nullptr };
  19. char const * value { nullptr };
  20. int index { 0 };
  21. /**
  22. * @brief Move to the next argument
  23. *
  24. * @param[out] key key of the next argument
  25. */
  26. inline next_result next(std::string* key = nullptr);
  27. };
  28. }