.TH "rte_argparse.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_argparse.h
.SH SYNOPSIS
.br
.PP
\fR#include <stdbool\&.h>\fP
.br
\fR#include <stdint\&.h>\fP
.br
\fR#include <rte_bitops\&.h>\fP
.br
\fR#include <rte_compat\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBrte_argparse_arg\fP"
.br
.ti -1c
.RI "struct \fBrte_argparse\fP"
.br
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "\fBtypedef\fP int(* \fBrte_arg_parser_t\fP) (uint32_t index, const char *value, void *opaque)"
.br
.in -1c
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBrte_argparse_value_required\fP { \fBRTE_ARGPARSE_VALUE_NONE\fP, \fBRTE_ARGPARSE_VALUE_REQUIRED\fP, \fBRTE_ARGPARSE_VALUE_OPTIONAL\fP }"
.br
.ti -1c
.RI "enum \fBrte_argparse_value_type\fP { \fBRTE_ARGPARSE_VALUE_TYPE_NONE\fP = 0, \fBRTE_ARGPARSE_VALUE_TYPE_INT\fP, \fBRTE_ARGPARSE_VALUE_TYPE_U8\fP, \fBRTE_ARGPARSE_VALUE_TYPE_U16\fP, \fBRTE_ARGPARSE_VALUE_TYPE_U32\fP, \fBRTE_ARGPARSE_VALUE_TYPE_U64\fP, \fBRTE_ARGPARSE_VALUE_TYPE_STR\fP, \fBRTE_ARGPARSE_VALUE_TYPE_BOOL\fP, \fBRTE_ARGPARSE_VALUE_TYPE_CORELIST\fP }"
.br
.ti -1c
.RI "enum \fBrte_argparse_arg_flags\fP { \fBRTE_ARGPARSE_FLAG_SUPPORT_MULTI\fP = RTE_BIT32(0) }"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "__rte_experimental int \fBrte_argparse_parse\fP (const struct \fBrte_argparse\fP *obj, int argc, char **argv)"
.br
.ti -1c
.RI "__rte_experimental void \fBrte_argparse_print_help\fP (FILE *stream, const struct \fBrte_argparse\fP *obj)"
.br
.ti -1c
.RI "__rte_experimental int \fBrte_argparse_parse_type\fP (const char *str, enum \fBrte_argparse_value_type\fP val_type, void *val)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Argument parsing API\&.

.PP
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]\&.

.PP
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\&.

.PP
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\&. 
.PP
Definition in file \fBrte_argparse\&.h\fP\&.
.SH "Typedef Documentation"
.PP 
.SS "\fBtypedef\fP int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque)"
Callback prototype used by parsing specified arguments\&.

.PP
\fBParameters\fP
.RS 4
\fIindex\fP The argument's index, coming from argument's val_set field\&. 
.br
\fIvalue\fP 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)\&. 
.br
\fIopaque\fP An opaque pointer coming from the caller\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success\&. Otherwise negative value is returned\&. 
.RE
.PP

.PP
Definition at line \fB145\fP of file \fBrte_argparse\&.h\fP\&.
.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBrte_argparse_value_required\fP"
enum defining whether an argument takes a value or not\&. 
.PP
\fBEnumerator\fP
.in +1c
.TP
\f(BIRTE_ARGPARSE_VALUE_NONE \fP
The argument takes no value\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_REQUIRED \fP
The argument must have a value\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_OPTIONAL \fP
The argument has optional value\&. 
.PP
Definition at line \fB43\fP of file \fBrte_argparse\&.h\fP\&.
.SS "enum \fBrte_argparse_value_type\fP"
enum defining the type of the argument, integer, boolean or just string 
.PP
\fBEnumerator\fP
.in +1c
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_NONE \fP
Argument takes no value, or value type not specified\&. Should be used when argument is to be handled via callback\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_INT \fP
The argument's value is int type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_U8 \fP
The argument's value is uint8 type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_U16 \fP
The argument's value is uint16 type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_U32 \fP
The argument's value is uint32 type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_U64 \fP
The argument's value is uint64 type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_STR \fP
The argument's value is string type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_BOOL \fP
The argument's value is boolean flag type\&. 
.TP
\f(BIRTE_ARGPARSE_VALUE_TYPE_CORELIST \fP
The argument's value is a corelist\&. 
.PP
Definition at line \fB53\fP of file \fBrte_argparse\&.h\fP\&.
.SS "enum \fBrte_argparse_arg_flags\fP"
Additional flags which may be specified for each argument 
.PP
\fBEnumerator\fP
.in +1c
.TP
\f(BIRTE_ARGPARSE_FLAG_SUPPORT_MULTI \fP
argument may be specified multiple times on the commandline 
.PP
Definition at line \fB77\fP of file \fBrte_argparse\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "__rte_experimental int rte_argparse_parse (const struct \fBrte_argparse\fP * obj, int argc, char ** argv)"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Parse parameters passed until all are processed, or until a "--" parameter is encountered\&.

.PP
\fBParameters\fP
.RS 4
\fIobj\fP Parser object\&. 
.br
\fIargc\fP Parameters count\&. 
.br
\fIargv\fP Array of parameters points\&.
.RE
.PP
\fBReturns\fP
.RS 4
number of arguments parsed (>= 0) on success\&. Otherwise negative error code is returned\&. 
.RE
.PP

.SS "__rte_experimental void rte_argparse_print_help (FILE * stream, const struct \fBrte_argparse\fP * obj)"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Output the help text information for the given argparse object\&.

.PP
\fBParameters\fP
.RS 4
\fIstream\fP Output file handle, e\&.g\&. stdout, stderr, on which to print the help text\&. 
.br
\fIobj\fP Parser object\&. 
.RE
.PP

.SS "__rte_experimental int rte_argparse_parse_type (const char * str, enum \fBrte_argparse_value_type\fP val_type, void * val)"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Parse the value from the input string based on the value type\&.

.PP
\fBParameters\fP
.RS 4
\fIstr\fP Input string\&. 
.br
\fIval_type\fP The value type, 
.RE
.PP
\fBSee also\fP
.RS 4
\fBrte_argparse_value_type\fP\&. 
.RE
.PP
\fBParameters\fP
.RS 4
\fIval\fP Saver for the value\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 on success\&. Otherwise negative value is returned\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
