Minimac4
Loading...
Searching...
No Matches
getopt_wrapper::option_with_desc Struct Reference

Extension of struct option that includes a description string. More...

#include <getopt_wrapper.hpp>

Inheritance diagram for getopt_wrapper::option_with_desc:
[legend]
Collaboration diagram for getopt_wrapper::option_with_desc:
[legend]

Public Member Functions

 option_with_desc (const char *_name, int _has_arg, int *_flag, int _val, const char *_description)
 Construct an option with description.
 

Public Attributes

const char * description
 Description of the command-line option for help output.
 

Detailed Description

Extension of struct option that includes a description string.

This structure inherits from the standard GNU struct option (used with getopt_long) and adds an additional field for a human-readable description. It is useful for generating formatted help/usage messages alongside command-line parsing.

Each option includes:

  • name: The long option name (e.g., "--input").
  • has_arg: Whether the option requires an argument (no_argument, required_argument, or optional_argument).
  • flag: Pointer to an int variable that is set if the option is found, or nullptr if the option’s value should be returned.
  • val: The short option character equivalent (e.g., ‘'i’). -description`: A string describing the option, shown in help output.

Example:

getopt_wrapper::option_with_desc opt("input", required_argument, nullptr, 'i',
"Path to input file");
Extension of struct option that includes a description string.
Definition getopt_wrapper.hpp:58

Constructor & Destructor Documentation

◆ option_with_desc()

getopt_wrapper::option_with_desc::option_with_desc ( const char * _name,
int _has_arg,
int * _flag,
int _val,
const char * _description )
inline

Construct an option with description.

Parameters
_nameLong option name (without leading dashes).
_has_argArgument requirement (no_argument, required_argument, optional_argument).
_flagPointer to variable set if option is found, or nullptr.
_valValue returned (or short option character).
_descriptionHuman-readable description of the option.

Member Data Documentation

◆ description

const char* getopt_wrapper::option_with_desc::description

Description of the command-line option for help output.


The documentation for this struct was generated from the following file: