rte_argparse.h(3)

πŸ“¦
version 25.11.3 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– rte_argparse.h πŸ’–

okay bestie, so this is a page from the Library Functions Manual β€” it's all about rte_argparse.h, the argument-parsing header from DPDK. Sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

rte_argparse.h β€” that's the whole name, she's lowkey mysterious like that πŸ’…


🌸 SYNOPSIS 🌸

First things first, you gotta pull in the header squad:

#include <stdbool.h>
#include <stdint.h>
#include <rte_bitops.h>
#include <rte_compat.h>

πŸŽ€ Data Structures

  • struct rte_argparse_arg
  • struct rte_argparse

πŸŽ€ Typedefs

  • typedef int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque)

πŸŽ€ Enumerations

  • enum rte_argparse_value_required β€” with values RTE_ARGPARSE_VALUE_NONE, RTE_ARGPARSE_VALUE_REQUIRED, RTE_ARGPARSE_VALUE_OPTIONAL
  • enum rte_argparse_value_type β€” with values RTE_ARGPARSE_VALUE_TYPE_NONE = 0, RTE_ARGPARSE_VALUE_TYPE_INT, RTE_ARGPARSE_VALUE_TYPE_U8, RTE_ARGPARSE_VALUE_TYPE_U16, RTE_ARGPARSE_VALUE_TYPE_U32, RTE_ARGPARSE_VALUE_TYPE_U64, RTE_ARGPARSE_VALUE_TYPE_STR, RTE_ARGPARSE_VALUE_TYPE_BOOL, RTE_ARGPARSE_VALUE_TYPE_CORELIST
  • enum rte_argparse_arg_flags β€” with value RTE_ARGPARSE_FLAG_SUPPORT_MULTI = RTE_BIT32(0)

πŸŽ€ Functions

  • __rte_experimental int rte_argparse_parse (const struct rte_argparse *obj, int argc, char **argv)
  • __rte_experimental void rte_argparse_print_help (FILE *stream, const struct rte_argparse *obj)
  • __rte_experimental int rte_argparse_parse_type (const char *str, enum rte_argparse_value_type val_type, void *val)

πŸ¦‹ Detailed Description πŸ¦‹

It's an Argument parsing API. Periodt.

The argument parsing API makes writing a user-friendly command-line program so easy, no cap. Your program says what arguments it needs, and the API goes and parses those arguments out of [argc, argv] for you. Iconic behaviour honestly πŸ‘‘

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.
fr fr that's the whole vibe of the file β€” Definition in file rte_argparse.h.

πŸ’œ Typedef Documentation πŸ’œ

typedef int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque)

Callback prototype used by parsing specified arguments. She's the one who gets called when things need parsing 🫢

Parameters

  • 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.

Returns

0 on success. Otherwise negative value is returned.

Definition at line 145 of file rte_argparse.h.


πŸ’œ Enumeration Type Documentation πŸ’œ

enum rte_argparse_value_required

enum defining whether an argument takes a value or not. like... does she come with a plus-one 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 rte_argparse_value_type

enum defining the type of the argument β€” integer, boolean or just string πŸŽ€

Enumerator

  • RTE_ARGPARSE_VALUE_TYPE_NONE β€” Argument takes no value, or value type not specified. Should be used when argument is to be handled via callback.
  • RTE_ARGPARSE_VALUE_TYPE_INT β€” The argument's value is int type.
  • RTE_ARGPARSE_VALUE_TYPE_U8 β€” The argument's value is uint8 type.
  • RTE_ARGPARSE_VALUE_TYPE_U16 β€” The argument's value is uint16 type.
  • RTE_ARGPARSE_VALUE_TYPE_U32 β€” The argument's value is uint32 type.
  • RTE_ARGPARSE_VALUE_TYPE_U64 β€” The argument's value is uint64 type.
  • RTE_ARGPARSE_VALUE_TYPE_STR β€” The argument's value is string type.
  • RTE_ARGPARSE_VALUE_TYPE_BOOL β€” The argument's value is boolean flag type.
  • RTE_ARGPARSE_VALUE_TYPE_CORELIST β€” The argument's value is a corelist.

Definition at line 53 of file rte_argparse.h.


enum rte_argparse_arg_flags

Additional flags which may be specified for each argument β€” lil extras you can sprinkle on top ✨

Enumerator

  • RTE_ARGPARSE_FLAG_SUPPORT_MULTI β€” argument may be specified multiple times on the commandline

Definition at line 77 of file rte_argparse.h.


πŸ”₯ Function Documentation πŸ”₯

__rte_experimental int rte_argparse_parse (const struct rte_argparse * obj, int argc, char ** argv)

Warning β€” EXPERIMENTAL: this API may change without prior notice. so like, don't get too attached bestie 😭

Parse parameters passed until all are processed, or until a "--" parameter is encountered.

Parameters

  • obj β€” Parser object.
  • argc β€” Parameters count.
  • argv β€” Array of parameters points.

Returns

number of arguments parsed (>= 0) on success. Otherwise negative error code is returned.


__rte_experimental void rte_argparse_print_help (FILE * stream, const struct rte_argparse * obj)

Warning β€” EXPERIMENTAL: this API may change without prior notice.

Output the help text information for the given argparse object. she literally does the talking for you, main character energy πŸ‘‘

Parameters

  • stream β€” Output file handle, e.g. stdout, stderr, on which to print the help text.
  • obj β€” Parser object.

__rte_experimental int rte_argparse_parse_type (const char * str, enum rte_argparse_value_type val_type, void * val)

Warning β€” EXPERIMENTAL: this API may change without prior notice.

Parse the value from the input string based on the value type.

Parameters

  • str β€” Input string.
  • val_type β€” The value type,

See also

rte_argparse_value_type.

Parameters

  • val β€” Saver for the value.

Returns

0 on success. Otherwise negative value is returned.


🌈 Author 🌈

Generated automatically by Doxygen for DPDK from the source code.


aaaand that's the whole thing bestie, hope you ate it up πŸ½οΈπŸ’– This page came from DPDK, Version 25.11.3 β€” like, the manual-page header calls it rte_argparse.h(3), and the footer is that same DPDK version stamp. mwah, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from