pargv.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * pargv.h
  3. */
  4. /**
  5. \ingroup clish
  6. \defgroup clish_pargv pargv
  7. @{
  8. \brief This class represents a vector of command line arguments.
  9. */
  10. #ifndef _clish_pargv_h
  11. #define _clish_pargv_h
  12. typedef enum {
  13. CLISH_LINE_OK,
  14. CLISH_LINE_PARTIAL,
  15. CLISH_BAD_CMD,
  16. CLISH_BAD_PARAM,
  17. CLISH_BAD_HISTORY
  18. } clish_pargv_status_t;
  19. typedef struct clish_pargv_s clish_pargv_t;
  20. typedef struct clish_parg_s clish_parg_t;
  21. #include "clish/ptype.h"
  22. #include "clish/command.h"
  23. #include "clish/param.h"
  24. /*=====================================
  25. * PARGV INTERFACE
  26. *===================================== */
  27. /*-----------------
  28. * meta functions
  29. *----------------- */
  30. clish_pargv_t *clish_pargv_new(void);
  31. /*-----------------
  32. * methods
  33. *----------------- */
  34. void clish_pargv_delete(clish_pargv_t * instance);
  35. const clish_parg_t *clish_pargv_find_arg(clish_pargv_t * instance,
  36. const char *name);
  37. int clish_pargv_insert(clish_pargv_t * instance,
  38. const clish_param_t * param, const char *value);
  39. clish_pargv_status_t clish_pargv_analyze(clish_pargv_t *instance,
  40. const clish_command_t * cmd,
  41. void *context,
  42. const char *line,
  43. size_t offset);
  44. clish_pargv_status_t clish_pargv_parse(clish_pargv_t *instance,
  45. const clish_command_t * cmd,
  46. void *context,
  47. clish_paramv_t *paramv,
  48. const lub_argv_t *argv,
  49. unsigned *idx, clish_pargv_t *last, unsigned need_index);
  50. void clish_pargv_dump(const clish_pargv_t * instance);
  51. /*-----------------
  52. * attributes
  53. *----------------- */
  54. unsigned clish_pargv__get_count(clish_pargv_t * instance);
  55. clish_parg_t *clish_pargv__get_parg(clish_pargv_t * instance, unsigned index);
  56. const clish_param_t *clish_pargv__get_param(clish_pargv_t * instance,
  57. unsigned index);
  58. /*=====================================
  59. * PARG INTERFACE
  60. *===================================== */
  61. /*-----------------
  62. * meta functions
  63. *----------------- */
  64. /*-----------------
  65. * methods
  66. *----------------- */
  67. void clish_parg_dump(const clish_parg_t * instance);
  68. /*-----------------
  69. * attributes
  70. *----------------- */
  71. const char *clish_parg__get_name(const clish_parg_t * instance);
  72. const char *clish_parg__get_value(const clish_parg_t * instance);
  73. const clish_ptype_t *clish_parg__get_ptype(const clish_parg_t * instance);
  74. #endif /* _clish_pargv_h */
  75. /** @} clish_pargv */