command_parser.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*******************************************************************************
  2. Copyright 2019 Yepkit Lda (www.yepkit.com)
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. *******************************************************************************/
  13. #ifndef _COMMAND_PARSER_H_
  14. #define _COMMAND_PARSER_H_
  15. struct command_parameter {
  16. char *name;
  17. struct command_parameter *next;
  18. };
  19. struct command_option {
  20. char *name;
  21. struct command_parameter *parameters;
  22. struct command_option *next;
  23. };
  24. struct command_line {
  25. char *app_name;
  26. struct command_option *options;
  27. };
  28. /**
  29. * \defgroup command_line Command line
  30. */
  31. /**
  32. * \ingroup command_line
  33. * \brief Parses the command line and sets the command object.
  34. *
  35. */
  36. class CommandLine {
  37. public:
  38. CommandLine();
  39. ~CommandLine();
  40. /**
  41. * \brief Processes the command line and sets the command property.
  42. */
  43. int parse(int argc, char **argv);
  44. /**
  45. * \brief Iterates through the command_line object and looks for a board option.
  46. *
  47. * \param board_name board name.
  48. *
  49. * \retval 0 board is in options.
  50. * \retval -1 board is not in option.
  51. *
  52. */
  53. int is_board(char *board_name);
  54. protected:
  55. private:
  56. struct command_line command;
  57. };
  58. #endif