|
tclap 1.4.0
|
The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes. More...
#include <CmdLine.h>


Classes | |
| struct | MessageTranslator |
| Optional callback used to localize user-facing strings. More... | |
| struct | MessageTranslatorImpl |
| class | Registration |
Public Member Functions | |
| CmdLine (const std::string &message, const char delimiter=' ', const std::string &version="none", bool helpAndVersion=true) | |
| Command line constructor. | |
| virtual | ~CmdLine () |
| Deletes any resources allocated by a CmdLine object. | |
| ArgContainer & | add (Arg &a) |
| Adds an argument to the list of arguments to be parsed. | |
| ArgContainer & | add (Arg *a) |
| An alternative add. | |
| ArgContainer & | add (ArgGroup &args) |
| Adds an argument group to the list of arguments to be parsed. | |
| void | addToArgList (Arg *a) |
| void | xorAdd (Arg &a, Arg &b) |
| void | xorAdd (const std::vector< Arg * > &xors) |
| void | parse (int argc, const char *const *argv) |
| Parses the command line. | |
| void | parse (std::vector< std::string > &args) |
| Parses the command line. | |
| void | setOutput (CmdLineOutput *co) |
| std::string | getVersion () const |
| Returns the version string. | |
| std::string | getProgramName () const |
| Returns the program name string. | |
| std::list< Arg * > | getArgList () const |
| std::list< ArgGroup * > | getArgGroups () |
| Returns the list of ArgGroups. | |
| char | getDelimiter () const |
| Returns the delimiter string. | |
| std::string | getMessage () const |
| Returns the message string. | |
| bool | hasHelpAndVersion () const |
| Indicates whether or not the help and version switches were created automatically. | |
| void | setExceptionHandling (const bool state) |
| Disables or enables CmdLine's internal parsing exception handling. | |
| bool | hasExceptionHandling () const |
| Returns the current state of the internal exception handling. | |
| void | reset () |
| Allows the CmdLine object to be reused. | |
| void | ignoreUnmatched (const bool ignore) |
| Allows unmatched args to be ignored. | |
| template<typename T > | |
| void | setMessageTranslator (const T &translator) |
| Sets an optional message translator callback. | |
| std::string | translateMessage (const std::string &messageId, const std::string &fallback) const |
| Translates a built-in message. | |
| void | beginIgnoring () |
| Begin ignoring arguments since the "--" argument was specified. | |
| bool | ignoreRest () |
| Whether to ignore the rest. | |
Public Member Functions inherited from TCLAP::CmdLineInterface | |
| virtual | ~CmdLineInterface () |
| Destructor. | |
| void | parse (std::vector< std::string > &args) |
| Parses the command line. | |
Public Member Functions inherited from TCLAP::ArgContainer | |
| virtual | ~ArgContainer () |
Protected Member Functions | |
| bool | attachGroup (ArgGroup &group) |
| void | missingArgsException (const std::list< ArgGroup * > &missing) |
| Throws an exception listing the missing args. | |
| bool | _emptyCombined (const std::string &s) |
| Checks whether a name/flag string matches entirely matches the Arg::blankChar. | |
Protected Attributes | |
| std::list< Arg * > | _argList |
| The list of arguments that will be tested against the command line. | |
| StandaloneArgs | _standaloneArgs |
| StandaloneArgs | _autoArgs |
| std::list< ArgGroup * > | _argGroups |
| Some args have set constraints on them (i.e., exactly or at most one must be specified. | |
| std::string | _progName |
| The name of the program. | |
| std::string | _message |
| A message used to describe the program. | |
| std::string | _version |
| The version to be displayed with the –version switch. | |
| int | _numRequired |
| The number of arguments that are required to be present on the command line. | |
| char | _delimiter |
| The character that is used to separate the argument flag/name from the value. | |
| bool | _hasOptionalUnlabeledArg |
| bool | _registrationActive |
| DeferDelete | _deleteOnExit |
| Add pointers that should be deleted as part of cleanup when this object is destroyed. | |
| StdOutput | _defaultOutput |
| Default output handler if nothing is specified. | |
| CmdLineOutput * | _output |
| Object that handles all output for the CmdLine. | |
| bool | _handleExceptions |
| Should CmdLine handle parsing exceptions internally? | |
| MessageTranslator * | _messageTranslator |
| SwitchArg * | _ignoreArg |
| Built-in arguments whose descriptions may need refreshing when the translator changes. | |
| SwitchArg * | _helpArg |
| SwitchArg * | _versionArg |
The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes.
|
inline |
Command line constructor.
Defines how the arguments will be parsed.
| message | - The message to be used in the usage output. |
| delimiter | - The character that is used to separate the argument flag/name from the value. Defaults to ' ' (space). |
| version | - The version number to be used in the –version switch. |
| helpAndVersion | - Whether or not to create the Help and Version switches. Defaults to true. |
|
inlinevirtual |
Deletes any resources allocated by a CmdLine object.
Definition at line 260 of file CmdLine.h.
References _messageTranslator.
|
inlineprotected |
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
Used when multiple switches are combined into a single argument.
| s | - The message to be used in the usage. |
Definition at line 719 of file CmdLine.h.
References TCLAP::Arg::blankChar(), and TCLAP::Arg::flagStartChar().

|
inlinevirtual |
Adds an argument to the list of arguments to be parsed.
| a | - Argument to be added. |
| A | reference to this so that add calls can be chained |
Implements TCLAP::CmdLineInterface.
Definition at line 587 of file CmdLine.h.
References add().
Referenced by add(), and attachGroup().

|
inlinevirtual |
An alternative add.
Functionally identical.
| a | - Argument to be added. |
| A | reference to this so that add calls can be chained |
Implements TCLAP::CmdLineInterface.
Definition at line 595 of file CmdLine.h.
References TCLAP::ArgGroup::_args, _standaloneArgs, TCLAP::CmdLine::Registration::add(), and TCLAP::CmdLine::Registration::commit().

|
inlinevirtual |
Adds an argument group to the list of arguments to be parsed.
All arguments in the group are added and the ArgGroup object will validate that the input matches its constraints.
| args | - Argument group to be added. |
| A | reference to this so that add calls can be chained |
Implements TCLAP::CmdLineInterface.
Definition at line 573 of file CmdLine.h.
References _argGroups, TCLAP::ArgGroup::_parser, TCLAP::CmdLine::Registration::add(), TCLAP::ArgGroup::begin(), TCLAP::CmdLine::Registration::commit(), and TCLAP::ArgGroup::end().

|
inlinevirtual |
Implements TCLAP::CmdLineInterface.
Definition at line 589 of file CmdLine.h.
References TCLAP::CmdLine::Registration::add(), and TCLAP::CmdLine::Registration::commit().

|
inlineprotectedvirtual |
Reimplemented from TCLAP::CmdLineInterface.
Definition at line 134 of file CmdLine.h.
References add().

|
inlinevirtual |
Begin ignoring arguments since the "--" argument was specified.
Implements TCLAP::CmdLineInterface.
|
inlinevirtual |
Returns the list of ArgGroups.
Implements TCLAP::CmdLineInterface.
Definition at line 325 of file CmdLine.h.
References _argGroups, and _autoArgs.
|
inlinevirtual |
|
inlinevirtual |
Returns the delimiter string.
Implements TCLAP::CmdLineInterface.
Definition at line 331 of file CmdLine.h.
References _delimiter.
|
inlinevirtual |
Returns the message string.
Implements TCLAP::CmdLineInterface.
Definition at line 332 of file CmdLine.h.
References _message.
|
inlinevirtual |
Returns the program name string.
Implements TCLAP::CmdLineInterface.
Definition at line 321 of file CmdLine.h.
References _progName.
|
inlinevirtual |
Returns the version string.
Implements TCLAP::CmdLineInterface.
Definition at line 319 of file CmdLine.h.
References _version.
|
inline |
Returns the current state of the internal exception handling.
| true | Parsing exceptions are handled internally. |
| false | Parsing exceptions are propagated to the caller. |
Definition at line 348 of file CmdLine.h.
References _handleExceptions.
|
inlinevirtual |
Indicates whether or not the help and version switches were created automatically.
Implements TCLAP::CmdLineInterface.
|
inlinevirtual |
Whether to ignore the rest.
Implements TCLAP::CmdLineInterface.
|
inline |
|
inlineprotected |
Throws an exception listing the missing args.
Definition at line 728 of file CmdLine.h.
References _argList, and translateMessage().

|
inlinevirtual |
Parses the command line.
| argc | - Number of arguments. |
| argv | - Array of arguments. |
Implements TCLAP::CmdLineInterface.
Definition at line 605 of file CmdLine.h.
References parse().
Referenced by parse().

|
inline |
Parses the command line.
| args | - A vector of strings representing the args. args[0] is still the program name. |
Definition at line 614 of file CmdLine.h.
References _handleExceptions, _output, TCLAP::CmdLineOutput::failure(), and TCLAP::ExitException::getExitStatus().

|
inlinevirtual |
|
inline |
Disables or enables CmdLine's internal parsing exception handling.
| state | Should CmdLine handle parsing exceptions internally? |
Definition at line 765 of file CmdLine.h.
References _handleExceptions.
|
inline |
Sets an optional message translator callback.
Definition at line 367 of file CmdLine.h.
References _messageTranslator.
|
inlinevirtual |
| co | - CmdLineOutput object that we want to use instead. |
Implements TCLAP::CmdLineInterface.
Definition at line 763 of file CmdLine.h.
References _output.
|
inlinevirtual |
Translates a built-in message.
Implements TCLAP::CmdLineInterface.
Definition at line 376 of file CmdLine.h.
References _messageTranslator, and TCLAP::CmdLine::MessageTranslator::translate().
Referenced by missingArgsException().

Implements TCLAP::CmdLineInterface.
Definition at line 496 of file CmdLine.h.
References xorAdd().
Referenced by xorAdd().

|
inlinevirtual |
Implements TCLAP::CmdLineInterface.
Definition at line 486 of file CmdLine.h.
References _deleteOnExit, and TCLAP::ExclusiveArgGroup::add().

|
protected |
Some args have set constraints on them (i.e., exactly or at most one must be specified.
Definition at line 100 of file CmdLine.h.
Referenced by add(), and getArgGroups().
|
protected |
The list of arguments that will be tested against the command line.
Definition at line 91 of file CmdLine.h.
Referenced by TCLAP::CmdLine::Registration::commit(), getArgList(), missingArgsException(), and reset().
|
protected |
Definition at line 94 of file CmdLine.h.
Referenced by getArgGroups().
|
protected |
|
protected |
|
protected |
The character that is used to separate the argument flag/name from the value.
Defaults to ' ' (space).
Definition at line 128 of file CmdLine.h.
Referenced by TCLAP::CmdLine::Registration::add(), and getDelimiter().
|
protected |
Should CmdLine handle parsing exceptions internally?
Definition at line 159 of file CmdLine.h.
Referenced by hasExceptionHandling(), parse(), and setExceptionHandling().
|
protected |
Definition at line 131 of file CmdLine.h.
Referenced by TCLAP::CmdLine::Registration::commit().
|
protected |
|
protected |
A message used to describe the program.
Used in the usage output.
Definition at line 110 of file CmdLine.h.
Referenced by getMessage().
|
protected |
Definition at line 180 of file CmdLine.h.
Referenced by setMessageTranslator(), translateMessage(), and ~CmdLine().
|
protected |
The number of arguments that are required to be present on the command line.
This is set dynamically, based on the Args added to the CmdLine object.
Definition at line 122 of file CmdLine.h.
Referenced by TCLAP::CmdLine::Registration::commit().
|
protected |
Object that handles all output for the CmdLine.
Definition at line 154 of file CmdLine.h.
Referenced by parse(), and setOutput().
|
protected |
The name of the program.
Set to argv[0].
Definition at line 105 of file CmdLine.h.
Referenced by getProgramName(), and reset().
|
protected |
Definition at line 132 of file CmdLine.h.
Referenced by TCLAP::CmdLine::Registration::Registration(), and TCLAP::CmdLine::Registration::~Registration().
|
protected |
|
protected |
The version to be displayed with the –version switch.
Definition at line 115 of file CmdLine.h.
Referenced by getVersion().