ost::CommandOption(3)
π NAME π
ost::CommandOption β okay so, bestie, this is the base class for all command line options. All of them. Every single one. Periodt. π
(straight out of the Library Functions Manual, no cap)
πΈ SYNOPSIS πΈ
#include <cmdoptns.h>
Inherited by ost::CommandOptionNoArg, and ost::CommandOptionWithArg.
π Public Types
enum OptionType { hasArg, noArg, trailing, collect }βOptionTypeis literally there to denote what type of option this is: with an arg, without an arg, or the trailing args. That's the whole job. π¦
π Public Member Functions
virtual ~CommandOption ()β a virtual destructor, just in case. π€·ββοΈCommandOption (const char *inOptionName, const char *inOptionLetter, const char *inDescription, OptionType inOptionType, bool inRequired=false, CommandOption **ppNext=&defaultCommandOptionList)β theCommandOptionconstructor. πvirtual void foundOption (CommandOptionParse *cop, const char *value=0)βfoundOptionis called by theCommandOptionParseobject during the parsing of the command line options.virtual void foundOption (CommandOptionParse *cop, const char **value, int num)β yep,foundOptionagain, and it's called by theCommandOptionParseobject during the parsing of the command line options.virtual void parseDone (CommandOptionParse *cop)β once parsing of command line options is complete, this method is called. β°virtual void performTask (CommandOptionParse *cop)β onceCommandOptionobjects have completed parsing and there are no errors, they may have some specific tasks to perform. πvirtual bool hasValue ()β for fields with the required flag set, this method is used to determine if the Option has satisfied it's required status.
π Public Attributes
const char * optionNameβ long option name, these will be preceded with--on the command line.const char * optionLetterβ option letter, these will be preceded with-on the command line.const char * descriptionβ a short description of the option for Usage messages.OptionType optionTypeβ this command option'sOptionType.bool requiredβtrueif this parameter is required.CommandOption * nextβ this nextCommandOptionin this list of options ornilif no more options exist.
π Detailed Description π
CommandOption is the base class for all command line options.
Command line options can be defined statically and used when constructing a command line parser onject using makeCommandOptionParse. This serves only as a base class to CommandOptionWithArg, CommandOptionRest or CommandOptionNoArg, which can also be used to derive more complex classes or even entire applications. π main character energy fr fr.
Author
Gianni Mariani gianni@mariani.ws
Examples
cmdlineopt.cpp.
π₯ Member Enumeration Documentation π₯
enum ost::CommandOption::OptionType
OptionType is for denoting what type of option this is, with an arg, without an arg or the trailing args. Option type. π«
Enumerator
hasArgβ this option is associated with a value.noArgβ this option is a flag only.trailingβ remaining of the command line arguments.collectβ collect values that are not a value to an option.
π Constructor & Destructor Documentation π
virtual ost::CommandOption::~CommandOption () [virtual]
A virtual destructor just in case. π
ost::CommandOption::CommandOption (const char * inOptionName, const char * inOptionLetter, const char * inDescription, OptionType inOptionType, bool inRequired = false, CommandOption ** ppNext = &defaultCommandOptionList)
The CommandOption constructor. Bestie, note the default values for required and ppNext β they're just sitting there being iconic. π
Parameters
inOptionNameβ long option nameinOptionLetterβ short letter nameinDescriptionβ short description of the optioninOptionTypeβ the type of this optioninRequiredβtrueif option is requiredppNextβ the linked list header
π¦ Member Function Documentation π¦
virtual void ost::CommandOption::foundOption (CommandOptionParse * cop, const char ** value, int num) [virtual]
foundOption is called by the CommandOptionParse object during the parsing of the command line options.
Parameters
copβ pointer to the command option parservalueβ an array of values of this optionnumβ number of values in the array
Reimplemented in ost::CommandOptionWithArg.
virtual void ost::CommandOption::foundOption (CommandOptionParse * cop, const char * value = 0) [virtual]
foundOption is called by the CommandOptionParse object during the parsing of the command line options.
Parameters
copβ pointer to the command option parservalueβ the value of this option
Reimplemented in ost::CommandOptionNoArg, and ost::CommandOptionWithArg.
virtual bool ost::CommandOption::hasValue () [virtual]
For fields with the required flag set, this method is used to determine if the Option has satisfied it's required status. The default methods simply returns true if any values have been found. This could be specialized to return true based on some other criteria.
Reimplemented in ost::CommandOptionWithArg.
virtual void ost::CommandOption::parseDone (CommandOptionParse * cop) [virtual]
Once parsing of command line options is complete, this method is called. This can be used to perform last minute checks on the options collected. β³
Parameters
copβ pointer to the command option parser
virtual void ost::CommandOption::performTask (CommandOptionParse * cop) [virtual]
Once CommandOption objects have completed parsing and there are no errors they may have some specific tasks to perform. PerformTask must return. No exceptions, no vibes-based skipping, it has to come back. π
Parameters
copβ pointer to the command option parser
π Member Data Documentation π
const char* ost::CommandOption::description
A short description of the option for Usage messages. e.g. Usage: mycommand : blah -f, --file <DESCRIPTION here>
CommandOption* ost::CommandOption::next
This next CommandOption in this list of options or nil if no more options exist.
const char* ost::CommandOption::optionLetter
option letter, these will be preceded with - on the command line. e.g. -f foo.x
const char* ost::CommandOption::optionName
Long option name, these will be preceded with -- on the command line. e.g. --file foo.x
OptionType ost::CommandOption::optionType
This command option's OptionType.
bool ost::CommandOption::required
True if this parameter is required. If the parameter is not supplied and required is true, an error will be flagged in the option processor. π¨ so like, don't forget it.
β Author β
Generated automatically by Doxygen for GNU CommonC++ from the source code.
π«Ά and that's the whole thing, bestie β every last flag, field and function. This page came from GNU CommonC++, dated Sun Dec 27 2020. Go forth and parse some options, you've got this. π β¨
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms