1
0

pargv.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 *viewid,
  31. const char *line,
  32. size_t offset,
  33. clish_pargv_status_t * status);
  34. /*-----------------
  35. * methods
  36. *----------------- */
  37. clish_pargv_t *clish_pargv_create(void);
  38. void clish_pargv_delete(clish_pargv_t * instance);
  39. const clish_parg_t *clish_pargv_find_arg(clish_pargv_t * instance,
  40. const char *name);
  41. int clish_pargv_insert(clish_pargv_t * instance,
  42. const clish_param_t * param, const char *value);
  43. clish_pargv_status_t clish_pargv_parse(clish_pargv_t * instance,
  44. const clish_command_t * cmd,
  45. const char *viewid,
  46. clish_paramv_t * paramv,
  47. const lub_argv_t * argv,
  48. unsigned *idx,
  49. clish_pargv_t * last,
  50. unsigned need_index);
  51. void clish_pargv_dump(const clish_pargv_t * instance);
  52. /*-----------------
  53. * attributes
  54. *----------------- */
  55. unsigned clish_pargv__get_count(clish_pargv_t * instance);
  56. clish_parg_t *clish_pargv__get_parg(clish_pargv_t * instance, unsigned index);
  57. const clish_param_t *clish_pargv__get_param(clish_pargv_t * instance,
  58. unsigned index);
  59. /*=====================================
  60. * PARG INTERFACE
  61. *===================================== */
  62. /*-----------------
  63. * meta functions
  64. *----------------- */
  65. /*-----------------
  66. * methods
  67. *----------------- */
  68. void clish_parg_dump(const clish_parg_t * instance);
  69. /*-----------------
  70. * attributes
  71. *----------------- */
  72. const char *clish_parg__get_name(const clish_parg_t * instance);
  73. const char *clish_parg__get_value(const clish_parg_t * instance);
  74. const clish_ptype_t *clish_parg__get_ptype(const clish_parg_t * instance);
  75. #endif /* _clish_pargv_h */
  76. /** @} clish_pargv */