command_line.h 698 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2012-2023 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #pragma once
  6. namespace crown
  7. {
  8. /// Helper for parsing command line.
  9. ///
  10. /// @ingroup Core
  11. struct CommandLine
  12. {
  13. int _argc;
  14. const char **_argv;
  15. /// Constructor.
  16. CommandLine(int argc, const char **argv);
  17. /// Returns the i-th parameter of the option identified by
  18. /// @a longopt or @a shortopt, or NULL if the parameter does not exist.
  19. const char *get_parameter(int i, const char *longopt, char shortopt = '\0');
  20. /// Returns whether the command line has the option identified
  21. /// by @a longopt or @a shortopt.
  22. bool has_option(const char *longopt, char shortopt = '\0');
  23. };
  24. } // namespace crown