|
DPDK 25.07.0
|
Go to the source code of this file.
Data Structures | |
| struct | rte_argparse_arg |
| struct | rte_argparse |
Typedefs | |
| typedef int(* | rte_arg_parser_t) (uint32_t index, const char *value, void *opaque) |
Functions | |
| __rte_experimental int | rte_argparse_parse (const struct rte_argparse *obj, int argc, char **argv) |
| __rte_experimental int | rte_argparse_parse_type (const char *str, enum rte_argparse_value_type val_type, void *val) |
Argument parsing API.
The argument parsing API makes it easy to write user-friendly command-line program. The program defines what arguments it requires, and the API will parse those arguments from [argc, argv].
The API provides the following functions: 1) Support parsing optional argument (which could take with no-value, required-value and optional-value. 2) Support parsing positional argument (which must take with required-value). 3) Support automatic generate usage information. 4) Support issue errors when provided with invalid arguments.
There are two ways to parse arguments: 1) AutoSave: for which known value types, the way can be used. 2) Callback: will invoke user callback to parse.
Definition in file rte_argparse.h.
| typedef int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque) |
Callback prototype used by parsing specified arguments.
| index | The argument's index, coming from argument's val_set field. |
| value | The value corresponding to the argument, it may be NULL (e.g. the argument has no value, or the argument has optional value but doesn't provided value). |
| opaque | An opaque pointer coming from the caller. |
Definition at line 143 of file rte_argparse.h.
enum defining whether an argument takes a value or not.
| Enumerator | |
|---|---|
| RTE_ARGPARSE_VALUE_NONE | The argument takes no value. |
| RTE_ARGPARSE_VALUE_REQUIRED | The argument must have a value. |
| RTE_ARGPARSE_VALUE_OPTIONAL | The argument has optional value. |
Definition at line 43 of file rte_argparse.h.
enum defining the type of the argument, integer, boolean or just string
Definition at line 53 of file rte_argparse.h.
Additional flags which may be specified for each argument
| Enumerator | |
|---|---|
| RTE_ARGPARSE_FLAG_SUPPORT_MULTI | argument may be specified multiple times on the commandline |
Definition at line 75 of file rte_argparse.h.
| __rte_experimental int rte_argparse_parse | ( | const struct rte_argparse * | obj, |
| int | argc, | ||
| char ** | argv | ||
| ) |
Parse parameters passed until all are processed, or until a "--" parameter is encountered.
| obj | Parser object. |
| argc | Parameters count. |
| argv | Array of parameters points. |
| __rte_experimental int rte_argparse_parse_type | ( | const char * | str, |
| enum rte_argparse_value_type | val_type, | ||
| void * | val | ||
| ) |
Parse the value from the input string based on the value type.
| str | Input string. |
| val_type | The value type, |
| val | Saver for the value. |