ost::CommandOption(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸŽ€ 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 } β€” OptionType is 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) β€” the CommandOption constructor. πŸ’–
  • virtual void foundOption (CommandOptionParse *cop, const char *value=0) β€” foundOption is called by the CommandOptionParse object during the parsing of the command line options.
  • virtual void foundOption (CommandOptionParse *cop, const char **value, int num) β€” yep, foundOption again, and it's called by the CommandOptionParse object 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) β€” once CommandOption objects 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's OptionType.
  • bool required β€” true if this parameter is required.
  • CommandOption * next β€” this next CommandOption in this list of options or nil if 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 name
  • inOptionLetter β€” short letter name
  • inDescription β€” short description of the option
  • inOptionType β€” the type of this option
  • inRequired β€” true if option is required
  • ppNext β€” 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 parser
  • value β€” an array of values of this option
  • num β€” 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 parser
  • value β€” 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