libcyberradio  22.01.24
AppOption Class Reference

Defines a command-line option that is supported by an application. More...

#include <App.h>

Public Member Functions

 AppOption ()
 Constructs an empty AppOption object.
 
 AppOption (const std::string &shortName, const std::string &longName, int valueType, void *valuePtr, const std::string &helpArgName, const std::string &helpText, bool showDefault)
 Constructs an AppOption object from initial parameters. More...
 
 AppOption (const AppOption &opt)
 Constructs an AppOption object as a copy of another. More...
 
virtual AppOptionoperator= (const AppOption &opt)
 Makes one AppOption object equivalent to another. More...
 
virtual ~AppOption ()
 Destroys an AppOption object.
 

Data Fields

std::string shortName
 Short option name, without leading hyphen. More...
 
std::string longName
 Long option name, without leading hyphens. More...
 
int valueType
 Type of value that this option sets. More...
 
void * valuePtr
 Pointer to a variable that holds the option value.
 
std::string helpArgName
 Option argument name to display in the help text.
 
std::string helpText
 Option help text.
 
bool showDefault
 Show the default value in the option help text. More...
 

Static Public Attributes

static int TYPE_NONE
 Option does not set a value.
 
static int TYPE_INTEGER
 Option sets an integer value.
 
static int TYPE_FLOAT
 Option sets a floating-point value.
 
static int TYPE_DOUBLE
 Option sets a double-precision floating-point value.
 
static int TYPE_STRING
 Option sets a string value.
 
static int TYPE_BOOLEAN
 Option explicitly sets a boolean value.
 
static int TYPE_BOOLEAN_SET_TRUE
 Option sets a boolean value that is False by default but becomes True if this option is specified.
 
static int TYPE_BOOLEAN_SET_FALSE
 Option sets a boolean value that is True by default but becomes False if this option is specified.
 

Detailed Description

Defines a command-line option that is supported by an application.

Definition at line 28 of file App.h.

Constructor & Destructor Documentation

◆ AppOption() [1/2]

AppOption ( const std::string &  shortName,
const std::string &  longName,
int  valueType,
void *  valuePtr,
const std::string &  helpArgName,
const std::string &  helpText,
bool  showDefault 
)

Constructs an AppOption object from initial parameters.

Parameters
shortNameShort option name, without leading hyphen. If empty, this option does not support short format.
longNameLong option name, without leading hyphens. If empty, this option does not support long format.
valueTypeType of value that this option sets. Must be one of the AppOption::TYPE_* constants.
valuePtrPointer to a variable that holds the option value.
helpArgNameOption argument name to display in the help text.
helpTextOption help text.
showDefaultWhether or not to show the default value of the option in the help text. The default value will be appended to the help text given in helpText.

Definition at line 44 of file App.cpp.

◆ AppOption() [2/2]

AppOption ( const AppOption opt)

Constructs an AppOption object as a copy of another.

Parameters
optThe AppOption object being copied.

Definition at line 58 of file App.cpp.

Member Function Documentation

◆ operator=()

AppOption & operator= ( const AppOption opt)
virtual

Makes one AppOption object equivalent to another.

Parameters
optThe AppOption object being copied.

Definition at line 69 of file App.cpp.

Field Documentation

◆ longName

std::string longName

Long option name, without leading hyphens.

If empty, this option does not support long format.

Definition at line 91 of file App.h.

◆ shortName

std::string shortName

Short option name, without leading hyphen.

If empty, this option does not support short format.

Definition at line 86 of file App.h.

◆ showDefault

bool showDefault

Show the default value in the option help text.

The default value is obtained from the variable pointed to by valuePtr.

Definition at line 113 of file App.h.

◆ valueType

int valueType

Type of value that this option sets.

Must be one of the AppOption::TYPE_* constants.

Definition at line 96 of file App.h.


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