|
Cthulhu
0.2.10
Cthulhu compiler collection
|
Command line argument parsing TODO: reduce the amount of allocations by allowing config to accept string views TODO: nicely support error propagation out of the parser. More...

Typedefs | |
| typedef bool(* | ap_event_t) (ap_t *ap, const cfg_field_t *param, const void *value, void *data) |
| callback for a parameter event called when a parameter is parsed return true to indicate the event was handled, false to continue to the next handler More... | |
Functions | |
| CT_ARGPARSE_API ap_t * | ap_new (cfg_group_t *config, arena_t *arena) |
| create a new parser instance More... | |
| CT_ARGPARSE_API void | ap_update (ap_t *self) |
| update the parser with the latest config More... | |
| CT_ARGPARSE_API void | ap_event (ap_t *self, const cfg_field_t *param, ap_event_t callback, void *data) |
| add a callback event to a parameter More... | |
| CT_ARGPARSE_API int | ap_parse_args (ap_t *self, int argc, const char **argv) |
| parse a command line More... | |
| CT_ARGPARSE_API int | ap_parse (ap_t *self, const char *str) |
| parse a string More... | |
| CT_ARGPARSE_API vector_t * | ap_get_posargs (ap_t *self) |
| get all positional arguments More... | |
| CT_ARGPARSE_API vector_t * | ap_get_unknown (ap_t *self) |
| get all unknown arguments More... | |
| CT_ARGPARSE_API vector_t * | ap_get_errors (ap_t *self) |
| get all errors More... | |
| CT_ARGPARSE_API size_t | ap_count_params (ap_t *self) |
| get the number of processed arguments More... | |
Command line argument parsing TODO: reduce the amount of allocations by allowing config to accept string views TODO: nicely support error propagation out of the parser.
| typedef bool(* ap_event_t) (ap_t *ap, const cfg_field_t *param, const void *value, void *data) |
callback for a parameter event called when a parameter is parsed return true to indicate the event was handled, false to continue to the next handler
| ap | the parser instance |
| param | the parameter that triggered the event, may be NULL for positional args |
| value | the value of the parameter, NULL for positional args, mpz_t for int, const char * for string, and bool* for bool |
| data | the data passed to ap_event |
| true | if the event was handled |
| false | if the event was not handled |
Definition at line 44 of file argparse.h.
| CT_ARGPARSE_API size_t ap_count_params | ( | ap_t * | self | ) |
get the number of processed arguments
| self | the parser instance |
Definition at line 181 of file argparse.c.
| CT_ARGPARSE_API void ap_event | ( | ap_t * | self, |
| const cfg_field_t * | param, | ||
| ap_event_t | callback, | ||
| void * | data | ||
| ) |
add a callback event to a parameter
| self | the parser instance |
| param | the parameter to add the event to |
| callback | the callback to add |
| data | the data to pass to the callback |
Definition at line 139 of file argparse.c.
get all errors
| self | the parser instance |
Definition at line 174 of file argparse.c.
get all positional arguments
| self | the parser instance |
Definition at line 158 of file argparse.c.
get all unknown arguments
| self | the parser instance |
Definition at line 166 of file argparse.c.
| CT_ARGPARSE_API ap_t* ap_new | ( | cfg_group_t * | config, |
| arena_t * | arena | ||
| ) |
create a new parser instance
| config | the config object to use |
| arena | the arena to allocate from |
Definition at line 97 of file argparse.c.
| CT_ARGPARSE_API int ap_parse | ( | ap_t * | self, |
| const char * | str | ||
| ) |
| CT_ARGPARSE_API int ap_parse_args | ( | ap_t * | self, |
| int | argc, | ||
| const char ** | argv | ||
| ) |
| CT_ARGPARSE_API void ap_update | ( | ap_t * | self | ) |
update the parser with the latest config
| self | the parser instance |
Definition at line 128 of file argparse.c.