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

Structure for holding the definition of potential options to pass on the command line. More...

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

Public Types

enum  ArgPerm { NO_ARG = 0 , OPTIONAL_ARG , MANDATORY_ARG }
 Enumeration for whether or not an option permits/requires arguments. More...
 

Public Member Functions

 ArgOpt (char aShortArg, const char *aLongArg, ArgPerm aArgPerm=ArgPerm::NO_ARG)
 Construct an ArgOpt data structure. More...
 
void SetHelpString (const char *aHelpString)
 Set the help string of the option. More...
 
void SetArgHint (const char *aArgHint)
 Set the short argument hint string, describing the argument (eg "yes|no", "path", "value) More...
 
void SetCallback (argCallback aCallback)
 Set the callback to be called when the option is detected. More...
 
template<class T >
void SetCallback (argCallbackMemRaw< T > aCallback, T &aInstance)
 Set the callback to be called when the option is detected. More...
 
int GetCallCount (void)
 Get the number of times this option was detected during parsing. More...
 

Friends

class Args
 

Detailed Description

Structure for holding the definition of potential options to pass on the command line.

Member Enumeration Documentation

◆ ArgPerm

Enumeration for whether or not an option permits/requires arguments.

Enumerator
NO_ARG 

No argument allowed to option.

OPTIONAL_ARG 

Option has optional argument.

MANDATORY_ARG 

Option requires an argument to be provided.

Constructor & Destructor Documentation

◆ ArgOpt()

ca::ArgOpt::ArgOpt ( char  aShortArg,
const char *  aLongArg,
ArgPerm  aArgPerm = ArgPerm::NO_ARG 
)

Construct an ArgOpt data structure.

Parameters
aShortArgShort form option (or '\0' if none)
aLongArgLong form option (or NULL if none)
aArgPerm
See also
ArgPerm

Member Function Documentation

◆ GetCallCount()

int ca::ArgOpt::GetCallCount ( void  )
inline

Get the number of times this option was detected during parsing.

This is incremented just before calling the callback.

Returns
Count of the number of times this option has been detected so far during parsing.

◆ SetArgHint()

void ca::ArgOpt::SetArgHint ( const char *  aArgHint)
inline

Set the short argument hint string, describing the argument (eg "yes|no", "path", "value)

Parameters
aArgHintPointer to a arg hint string with static lifetime (e.g. a string constant)

◆ SetCallback() [1/2]

void ca::ArgOpt::SetCallback ( argCallback  aCallback)
inline

Set the callback to be called when the option is detected.

Parameters
aCallbackThe callback to be called, or NULL for none.

◆ SetCallback() [2/2]

template<class T >
void ca::ArgOpt::SetCallback ( argCallbackMemRaw< T >  aCallback,
T &  aInstance 
)
inline

Set the callback to be called when the option is detected.

Parameters
aCallbackFunction pointer to member function to call
aInstanceInstance to call the member function on

◆ SetHelpString()

void ca::ArgOpt::SetHelpString ( const char *  aHelpString)
inline

Set the help string of the option.

Parameters
aHelpStringPointer to a help string with static lifetime (e.g. a string constant)

Friends And Related Function Documentation

◆ Args

friend class Args
friend

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