Public Member Functions | Protected Attributes | List of all members
gnsstk::CommandOptionNOf Class Reference

Detailed Description

This is a special "command option" which is really a meta-option to make sure at least some specified number of a set of real options has been used. You may also set the maximum count (using the setMaxCount() method) to specify a maximum number of times the real options are used in total. The default maximum is the same as the minimum, that is, the default behavior is that you have to specify N exactly, no more, no less.

As an example, if you have real options x y and z as part of this grouping, and N=2, the user can specify xx or yy or zz or xy or xz and so on.

Warning
There's nothing to prevent you from, say, adding another meta-option to the list of mutually exclusive options contained in a CommandOptionNOf instance (or even itself), but the behavior if you try this is undefined.

Definition at line 501 of file CommandOption.hpp.

#include <CommandOption.hpp>

Inheritance diagram for gnsstk::CommandOptionNOf:
Inheritance graph
[legend]

Public Member Functions

void addOption (CommandOption *opt)
 Add an option to the list of mutually exclusive options. More...
 
virtual std::string checkArguments ()
 
 CommandOptionNOf (const unsigned long num)
 
std::vector< CommandOption * > which () const
 
virtual ~CommandOptionNOf ()
 Destructor. More...
 
- Public Member Functions inherited from gnsstk::CommandOption
 CommandOption (const CommandOptionFlag of, const CommandOptionType ot, const char shOpt, const std::string &loOpt, const std::string &desc, const bool req=false, CommandOptionVec &optVectorList=defaultCommandOptionList)
 
std::ostream & dumpValue (std::ostream &out) const
 Displays this->value to the stream out. More...
 
virtual std::string getArgString () const
 Returns a string with the argument format. More...
 
virtual unsigned long getCount () const
 
std::string getDescription () const
 Returns a formatted string with the description of this option. More...
 
std::string getFullOptionString () const
 
virtual std::string getOptionString () const
 
unsigned long getOrder (unsigned long idx=-1) const
 
const std::vector< std::string > & getValue () const
 
void setDescription (const std::string &desc)
 
CommandOptionsetMaxCount (const unsigned long l)
 
struct option toGetoptLongOption () const
 Returns a struct option for use with getopt_long. More...
 
std::string toGetoptShortOption () const
 Returns a string for use with getopt. More...
 
virtual ~CommandOption ()
 Destructor. More...
 

Protected Attributes

unsigned long N
 
CommandOptionVec optionVec
 
- Protected Attributes inherited from gnsstk::CommandOption
unsigned long count
 
std::string description
 The description for the help text. More...
 
std::string longOpt
 The string for the long option (for example, "--foo"). More...
 
unsigned long maxCount
 
CommandOptionFlag optFlag
 Flag for determining whether this option has an argument or not. More...
 
CommandOptionType optType
 
std::vector< unsigned long > order
 The order in which this option was encountered on the command line. More...
 
CommandOptionParserparser
 
bool required
 Whether or not this is a required command line option. More...
 
char shortOpt
 The character for the short option (for example, '-f'). More...
 
std::vector< std::string > value
 Any arguments passed with this option get put in here. More...
 

Additional Inherited Members

- Public Types inherited from gnsstk::CommandOption
enum  CommandOptionFlag { noArgument = 0, hasArgument = 1 }
 
enum  CommandOptionType { trailingType, stdType, metaType }
 
- Protected Member Functions inherited from gnsstk::CommandOption
 CommandOption ()
 Default Constructor. More...
 

Constructor & Destructor Documentation

◆ CommandOptionNOf()

gnsstk::CommandOptionNOf::CommandOptionNOf ( const unsigned long  num)
inline

CommandOptionNOf contructor. This sets the CommandOptionType for this object to metaType.

Definition at line 508 of file CommandOption.hpp.

◆ ~CommandOptionNOf()

virtual gnsstk::CommandOptionNOf::~CommandOptionNOf ( )
inlinevirtual

Destructor.

Definition at line 516 of file CommandOption.hpp.

Member Function Documentation

◆ addOption()

void gnsstk::CommandOptionNOf::addOption ( CommandOption opt)

Add an option to the list of mutually exclusive options.

Definition at line 343 of file CommandOption.cpp.

◆ checkArguments()

string gnsstk::CommandOptionNOf::checkArguments ( )
virtual

If you specified a format for the arguments (for example, digit or string), this function checks them to see if they match. If they don't, an error string is returned. If they do, an empty string is returned.

Reimplemented from gnsstk::CommandOption.

Definition at line 353 of file CommandOption.cpp.

◆ which()

std::vector< CommandOption * > gnsstk::CommandOptionNOf::which ( ) const
Returns
the command options that were used (empty vector if none).

Definition at line 381 of file CommandOption.cpp.

Member Data Documentation

◆ N

unsigned long gnsstk::CommandOptionNOf::N
protected

Definition at line 528 of file CommandOption.hpp.

◆ optionVec

CommandOptionVec gnsstk::CommandOptionNOf::optionVec
protected

Definition at line 527 of file CommandOption.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44