Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
ca::Args Class Reference

Class for parsing and handling options passed as command line arguments. More...

#include <posix/app/chilictl/common/Args.hpp>

Public Member Functions

 Args ()
 Default constructor, initialises empty arg parser. More...
 
ca_error ProcessOption (int &argi, int argc, const char *argv[])
 Process a single option from argv using the provided ArgOpt structures. More...
 
void PrintOptionHelpStrings (FILE *aOutFile)
 Print all of the option help strings to the 'out' file pointer in manpage format. More...
 
void AddOption (ArgOpt &aOption)
 Add an option definition to this parser. More...
 

Detailed Description

Class for parsing and handling options passed as command line arguments.

Conforms to POSIX, also supports GNU style long options.

Constructor & Destructor Documentation

◆ Args()

ca::Args::Args ( )
inline

Default constructor, initialises empty arg parser.

Member Function Documentation

◆ AddOption()

void ca::Args::AddOption ( ArgOpt aOption)
inline

Add an option definition to this parser.

The ArgOpt instance added should have a lifetime at least as long as the Args instance.

Parameters
aOptionThe option definition to add.

◆ PrintOptionHelpStrings()

void ca::Args::PrintOptionHelpStrings ( FILE *  aOutFile)

Print all of the option help strings to the 'out' file pointer in manpage format.

Parameters
aOutFileFILE to print to.

◆ ProcessOption()

ca_error ca::Args::ProcessOption ( int &  argi,
int  argc,
const char *  argv[] 
)

Process a single option from argv using the provided ArgOpt structures.

This function increments argi internally, and in the case where an option takes an argument, it may increment it more than once. If the end of options has been reached, or a non-option argument in encountered, CA_ERROR_NOT_HANDLED will be returned.

argi should begin at 1 to avoid processing the arg0, which is the executable name.

Parameters
argiCurrent index to process in argv. argi will be increased if processing is successful.
argcArgument count (number of args in argv)
argvArgument vector (Array of c-strings, representing the arguments)
Returns
Status of the processing
Return values
CA_ERROR_SUCCESSSuccessfully processed options
CA_ERROR_NOT_HANDLEDPositional argument encountered or end of arguments reached
CA_ERROR_INVALID_ARGSOption not recognised or incorrect usage

The documentation for this class was generated from the following files: