pargv.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_BAD_CMD,
  15. CLISH_BAD_PARAM,
  16. CLISH_BAD_HISTORY
  17. } clish_pargv_status_t;
  18. typedef struct clish_pargv_s clish_pargv_t;
  19. typedef struct clish_parg_s clish_parg_t;
  20. #include "clish/ptype.h"
  21. #include "clish/command.h"
  22. #include "clish/param.h"
  23. /*=====================================
  24. * PARGV INTERFACE
  25. *===================================== */
  26. /*-----------------
  27. * meta functions
  28. *----------------- */
  29. clish_pargv_t *clish_pargv_new(const clish_command_t * cmd,
  30. const char *line,
  31. size_t offset, clish_pargv_status_t * status);
  32. /*-----------------
  33. * methods
  34. *----------------- */
  35. clish_pargv_t *clish_pargv_create(void);
  36. void clish_pargv_delete(clish_pargv_t * instance);
  37. const clish_parg_t *clish_pargv_find_arg(clish_pargv_t * instance,
  38. const char *name);
  39. void
  40. clish_pargv_insert(clish_pargv_t * instance,
  41. const clish_param_t * param, const char *value);
  42. clish_pargv_status_t
  43. clish_pargv_parse(clish_pargv_t * instance,
  44. const clish_command_t * cmd,
  45. clish_paramv_t * paramv,
  46. const lub_argv_t * argv,
  47. unsigned *idx, clish_pargv_t * last, unsigned need_index);
  48. void clish_pargv_dump(const clish_pargv_t * instance);
  49. /*-----------------
  50. * attributes
  51. *----------------- */
  52. unsigned clish_pargv__get_count(clish_pargv_t * instance);
  53. clish_parg_t *clish_pargv__get_parg(clish_pargv_t * instance, unsigned index);
  54. const clish_param_t *clish_pargv__get_param(clish_pargv_t * instance,
  55. unsigned index);
  56. /*=====================================
  57. * PARG INTERFACE
  58. *===================================== */
  59. /*-----------------
  60. * meta functions
  61. *----------------- */
  62. /*-----------------
  63. * methods
  64. *----------------- */
  65. void clish_parg_dump(const clish_parg_t * instance);
  66. /*-----------------
  67. * attributes
  68. *----------------- */
  69. const char *clish_parg__get_name(const clish_parg_t * instance);
  70. const char *clish_parg__get_value(const clish_parg_t * instance);
  71. const clish_ptype_t *clish_parg__get_ptype(const clish_parg_t * instance);
  72. #endif /* _clish_pargv_h */
  73. /** @} clish_pargv */