|
Argument parser
Detailed Description
A couple of functions to parse the arguments of a program.
You can use those two functions to parse the arguments given to your program.
Two kinds of arguments are supported:
- Short arguments: "-c", "-c value" or "-cvalue"
- Long arguments: "--argument", "--agument value" or "--argument=value"
To check whether an argument that takes no value is present, use etk_argument_is_set().
To get the value of an argument, use etk_argument_value_get()
|
Functions |
void | etk_argument_get (int *argc, char ***argv) |
| Retrieves the arguments passed to etk_init_full().
|
Etk_Bool | etk_argument_is_set (const char *long_name, char short_name, Etk_Bool remove) |
| Checks whether the argument has been passed to the program.
|
Etk_Bool | etk_argument_value_get (const char *long_name, char short_name, Etk_Bool remove, char **value) |
| Gets the value of an argument passed to the program.
|
Function Documentation
void etk_argument_get |
( |
int * |
argc, |
|
|
char *** |
argv | |
|
) |
| | |
Retrieves the arguments passed to etk_init_full().
- Parameters:
-
| argc | the location where to store the number of arguments passed to etk_init_full() |
| argv | the location where to store the list of arguments passed to etk_init_full() |
Etk_Bool etk_argument_is_set |
( |
const char * |
long_name, |
|
|
char |
short_name, |
|
|
Etk_Bool |
remove | |
|
) |
| | |
Checks whether the argument has been passed to the program.
- Parameters:
-
| long_name | the complete name of the argument to find. If '--long_name' is found in argv, this function will return ETK_TRUE. You can set this param to NULL to ignore it |
| short_name | a shortcut for the argument to find. If '-short_name' is found in argv, this function will return ETK_TRUE. You can set this param to 0 to ignore it |
| remove | if remove is set to ETK_TRUE, the argument will be removed from the list of arguments passed to the program if the argument has been found |
- Returns:
- Returns ETK_TRUE if the argument has been found, ETK_FALSE otherwise
Etk_Bool etk_argument_value_get |
( |
const char * |
long_name, |
|
|
char |
short_name, |
|
|
Etk_Bool |
remove, |
|
|
char ** |
value | |
|
) |
| | |
Gets the value of an argument passed to the program.
- Parameters:
-
| long_name | the complete name of the argument to find. If --long_name is found in argv and is followed by a value, this function will return ETK_TRUE. You can set this param to NULL to ignore it |
| short_name | a shortcut for the argument to find. If -short_name is found in argv and is followed by a value, this function will return ETK_TRUE. You can set this param to 0 to ignore it |
| remove | if remove is ETK_TRUE, the argument and its value will be removed from the list of arguments passed to the program if they have been found |
| value | the location where to store the value of the argument. You'll have to free it when you no longer need it. This parameter should not be NULL, otherwise the function will return ETK_FALSE |
- Returns:
- Returns ETK_TRUE if the argument has been found and was followed by a value, ETK_FALSE otherwise
|
|