11 #ifndef INCLUDED_LIBCYBERRADIO_APP_H 12 #define INCLUDED_LIBCYBERRADIO_APP_H 17 #include "LibCyberRadio/Common/BasicList.h" 203 virtual void addOptionText(
const std::string& option,
const std::string& text);
227 virtual std::string wordWrappedText(
const std::string& text,
int width,
351 virtual void addOption(
const std::string& shortName,
const std::string& longName,
352 int valueType,
void *valuePtr,
353 const std::string& helpArgName,
const std::string& helpText,
373 virtual int parse(
int argc,
char **argv);
377 virtual void printUsage();
379 virtual int optionValueArg(
int valueType);
381 virtual std::string getDefault(
const AppOption& opt);
383 virtual int handleOptionReturn(
int opt,
const std::string& optarg);
386 virtual int handleOptionNone(
int optindex,
const std::string& optarg);
388 virtual int handleOptionInt(
int optindex,
const std::string& optarg);
390 virtual int handleOptionFloat(
int optindex,
const std::string& optarg);
392 virtual int handleOptionDouble(
int optindex,
const std::string& optarg);
394 virtual int handleOptionString(
int optindex,
const std::string& optarg);
396 virtual int handleOptionBool(
int optindex,
const std::string& optarg);
398 virtual int handleOptionBooleanSetTrue(
int optindex,
const std::string& optarg);
400 virtual int handleOptionBooleanSetFalse(
int optindex,
const std::string& optarg);
411 std::string _description;
412 std::string _version;
413 std::string _executable;
414 std::string _unparsedArgText;
415 std::string _epilogText;
416 bool _allowUnknownOption;
418 typedef int (
AppOptionParser::*OptionHelper)(
int optindex,
const std::string& optarg);
419 std::map<int, OptionHelper> _optionHelpers;
461 virtual int run(
int argc,
char *argv[]);
486 virtual int parseCommandLine(
int argc,
char *argv[]);
virtual ~App()
Destroys an App object.
void allowUnknownOption(bool allow=true)
Determines whether or not the parser will allow unknown options to pass through the parser without ge...
static int TYPE_NONE
Option does not set a value.
virtual AppOption & operator=(const AppOption &opt)
Makes one AppOption object equivalent to another.
std::string shortName
Short option name, without leading hyphen.
virtual void addPreOptionText(const std::string &text)
Adds text that gets displayed before the list of options.
virtual void defineOptions(const char *argv0)
Defines which command-line options are supported by the application, as well as any help text that is...
static int TYPE_BOOLEAN
Option explicitly sets a boolean value.
virtual ~AppHelpTextFormatter()
Destroys an AppHelpTextFormatter object.
void setExecutable(const std::string &executable)
Sets the portion of the usage information where the executable name is displayed. ...
void setVersion(const std::string &version)
Sets the portion of the usage information that represents the application version.
virtual int mainLoop()
Defines the application's main processing loop.
Formats help text for display on the screen.
static int TYPE_BOOLEAN_SET_TRUE
Option sets a boolean value that is False by default but becomes True if this option is specified...
void setDescription(const std::string &description)
Sets the portion of the usage information where the application description is displayed.
virtual ~AppOptionParser()
Destroys an AppOptionParser object.
void setDisplayWidth(int displayWidth=75)
Sets the display width of the usage information.
AppOptionParser()
Constructs an AppOptionParser object.
std::string version
The application version.
BASIC_LIST_CONTAINER< AppOption > AppOptionList
Defines a list of AppOption objects.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
static int TYPE_INTEGER
Option sets an integer value.
App()
Constructs an App object.
Defines functionality for LibCyberRadio applications.
BasicStringList unparsedArgs
The collection of arguments that were not dealt with by the parser during option parsing.
void * valuePtr
Pointer to a variable that holds the option value.
void setEpilogText(const std::string &epilogText)
Sets the epilog portion of the usage information; that is, the part that comes after the list of supp...
void setUnparsedArgText(const std::string &unparsedArgText)
Sets the portion of the usage information that represents the collection of unparsed arguments...
virtual std::string getFormattedText()
Gets the formatted help text.
virtual int run(int argc, char *argv[])
Runs the application.
virtual void addPostOptionText(const std::string &text)
Adds text that gets displayed after the list of options.
virtual void addOption(const AppOption &opt)
Adds an allowed option to the parser.
static int TYPE_DOUBLE
Option sets a double-precision floating-point value.
Provides basic application functionality.
Parses command-line options supported by the application.
static int TYPE_FLOAT
Option sets a floating-point value.
AppOption()
Constructs an empty AppOption object.
bool showDefault
Show the default value in the option help text.
std::string description
The application description.
std::string helpText
Option help text.
AppHelpTextFormatter(int displayWidth=75)
Constructs an AppHelpTextFormatter object.
std::string longName
Long option name, without leading hyphens.
static int TYPE_STRING
Option sets a string value.
virtual int parse(int argc, char **argv)
Parses the command-line options.
virtual void addOptionText(const std::string &option, const std::string &text)
Adds an option and its help text to the list of options.
virtual ~AppOption()
Destroys an AppOption object.
static int TYPE_BOOLEAN_SET_FALSE
Option sets a boolean value that is True by default but becomes False if this option is specified...
Defines a command-line option that is supported by an application.
int valueType
Type of value that this option sets.
std::string helpArgName
Option argument name to display in the help text.