ot::auxil
class CommandLineOption (abstract)
#include "ot/auxil/CommandLineOption.h"
An 'interface' class employed by the CommandLineParser to share the responsibility of recognising and storing command options.
Typically a command line option will have a long name and a short name alias, however it is possible for one instance of CommandLineOption to support many different commands names (see MultiListOption for an example of this).
enum ArgumentType { |
notknown =0, |
/* The option is not recognized */ |
|
none, |
/* The option takes no argument */ |
|
optional, |
/* The option takes an optional argument */ |
|
mandatory} |
/* The option always requires an argument */ |
| Constructor/Destructor Detail |
~CommandLineOption
virtual ~CommandLineOption()
-
setPresent
virtual void setPresent(const String& howSpecified,
OptionType optionTypeUsed,
const String& argument)=0
-
Called by the CommandLineParser once it has determined that this CommandLineOption has been specified on the command line being parsed.
It is usual practice for the implementation to store the fact that a command option has been specified together with any associated argument. The application can then interrogate the object later on to see which options have been specified by the user.
- Parameters:
howSpecified -
the option as it appears on the command line.
optionTypeUsed -
an indication if the option was recognised as a short or long option.
argument -
the value of the option's argument (if specified)
- Exceptions:
CommandLineException -
if the option is invalid and parsing should stop.
testLongOption
virtual ArgumentType testLongOption(const String& option) const=0
-
Called by the CommandLineParser to test if a long option contained within the command line matches the long option name accepted by this CommandLineOption.
In this case, the implementation should only check that the supplied option matches the first n characters of this option's long name (where n is the length of the supplied option string). This is to allow for long option abreviation.
If the passed option name does match, a value from the CommandLineOption::ArgumentType enumeration is returned to indicate whether an argument is expected for this option.
- Parameters:
option -
the option as contained within the command line being parsed.
- Returns:
-
One of the values from the CommandLineOption::ArgumentType enumeration. If the option does not match then notknown is returned.
testShortOption
virtual ArgumentType testShortOption(CharType option) const=0
-
Called by the CommandLineParser to test if a short option contained within the command line matches the short option name accepted by this CommandLineOption.
If the passed option name does match, a value from the CommandLineOption::ArgumentType enumeration is returned to indicate whether an argument is expected for this option.
- Parameters:
option -
the option as contained within the command line being parsed.
- Returns:
-
One of the values from the CommandLineOption::ArgumentType enumeration. If the option does not match then notknown is returned.
Found a bug or missing feature? Please email us at support@elcel.com