tclap 1.4.0
CmdLine.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3/******************************************************************************
4 *
5 * file: CmdLine.h
6 *
7 * Copyright (c) 2003, Michael E. Smoot .
8 * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
9 * Copyright (c) 2018, Google LLC
10 * All rights reserved.
11 *
12 * See the file COPYING in the top directory of this distribution for
13 * more information.
14 *
15 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 *****************************************************************************/
24
25#ifndef TCLAP_CMD_LINE_H
26#define TCLAP_CMD_LINE_H
27
29#include <tclap/SwitchArg.h>
32
33#include <tclap/HelpVisitor.h>
36
37#include <tclap/CmdLineOutput.h>
38#include <tclap/StdOutput.h>
39
40#include <tclap/Constraint.h>
45
46#include <tclap/ArgGroup.h>
47#include <tclap/DeferDelete.h>
48
49#include <algorithm>
50#include <cstdlib>
51#include <iomanip>
52#include <iostream>
53#include <list>
54#include <string>
55#include <vector>
56#include <utility>
57
58namespace TCLAP {
59
60class StandaloneArgs : public AnyOf {
61public:
63
65 for (iterator it = begin(); it != end(); it++) {
66 if (arg->conflictsWith(**it)) {
68 "Argument with same flag/name already exists!",
69 arg->longID());
70 }
71 }
72
73 _args.push_back(arg);
74
75 return *this;
76 }
77
78 bool showAsGroup() const { return false; }
79};
80
85class CmdLine : public CmdLineInterface {
86protected:
91 std::list<Arg *> _argList;
92
94 StandaloneArgs _autoArgs; // --help, --version, etc
95
100 std::list<ArgGroup *> _argGroups;
101
105 std::string _progName;
106
110 std::string _message;
111
115 std::string _version;
116
123
129
130 // Registration order, scoped to this parser rather than construction.
133 class Registration;
134 bool attachGroup(ArgGroup &group) {
135 add(group);
136 return true;
137 }
138
145
150
155
160
166 virtual std::string translate(const std::string &messageId,
167 const std::string &fallback) const = 0;
168 };
169
170 template <typename T>
173 MessageTranslatorImpl(const T &translator) : _translator(translator) {}
174 virtual std::string translate(const std::string &messageId,
175 const std::string &fallback) const {
176 return _translator(messageId, fallback);
177 }
178 };
179
181
189
193 void missingArgsException(const std::list<ArgGroup *> &missing);
194
201 bool _emptyCombined(const std::string &s);
202
203private:
207 CmdLine(const CmdLine &rhs);
208 CmdLine &operator=(const CmdLine &rhs);
209
214 void _constructor();
215
216 void _createIgnoreRestArgument();
217 void _createHelpAndVersionArguments();
218 void _refreshBuiltinDescriptions();
219
220 void _setProgramName(std::vector<std::string> &args);
221 int _parseArguments(std::vector<std::string> &args);
222 bool _processArgument(int &index, std::vector<std::string> &args,
223 int &requiredCount);
224 void _validateRequiredArguments(int requiredCount);
225
229 bool _helpAndVersion;
230
234 bool _ignoreUnmatched;
235
239 bool _ignoring;
240
241public:
254 CmdLine(const std::string &message, const char delimiter = ' ',
255 const std::string &version = "none", bool helpAndVersion = true);
256
260 virtual ~CmdLine() { delete _messageTranslator; }
261
268 ArgContainer &add(Arg &a);
269
276 ArgContainer &add(Arg *a);
277
288 ArgContainer &add(ArgGroup &args);
289
290 // Internal, do not use
291 void addToArgList(Arg *a);
292
296 void xorAdd(Arg &a, Arg &b);
297
301 void xorAdd(const std::vector<Arg *> &xors);
302
308 void parse(int argc, const char *const *argv);
309
315 void parse(std::vector<std::string> &args);
316
317 void setOutput(CmdLineOutput *co);
318
319 std::string getVersion() const { return _version; }
320
321 std::string getProgramName() const { return _progName; }
322
323 // TOOD: Get rid of getArgList
324 std::list<Arg *> getArgList() const { return _argList; }
325 std::list<ArgGroup *> getArgGroups() {
326 std::list<ArgGroup *> groups = _argGroups;
327 groups.push_back(&_autoArgs);
328 return groups;
329 }
330
331 char getDelimiter() const { return _delimiter; }
332 std::string getMessage() const { return _message; }
333 bool hasHelpAndVersion() const { return _helpAndVersion; }
334
340 void setExceptionHandling(const bool state);
341
349
353 void reset();
354
361 void ignoreUnmatched(const bool ignore);
362
366 template <typename T>
367 void setMessageTranslator(const T &translator) {
368 delete _messageTranslator;
370 _refreshBuiltinDescriptions();
371 }
372
376 std::string translateMessage(const std::string &messageId,
377 const std::string &fallback) const {
378 if (_messageTranslator != NULL) {
379 return _messageTranslator->translate(messageId, fallback);
380 }
381 return fallback;
382 }
383
384 void beginIgnoring() { _ignoring = true; }
385 bool ignoreRest() { return _ignoring; }
386};
387
389// Begin CmdLine.cpp
391
392inline CmdLine::CmdLine(const std::string &m, char delim, const std::string &v,
393 bool help)
394 : _argList(),
395 _standaloneArgs(),
396 _autoArgs(),
397 _argGroups(),
398 _progName("not_set_yet"),
399 _message(m),
400 _version(v),
401 _numRequired(0),
402 _delimiter(delim),
403 _hasOptionalUnlabeledArg(false),
404 _registrationActive(false),
405 _deleteOnExit(),
406 _defaultOutput(),
407 _output(&_defaultOutput),
408 _handleExceptions(true),
409 _messageTranslator(NULL),
410 _ignoreArg(NULL),
411 _helpArg(NULL),
412 _versionArg(NULL),
413 _helpAndVersion(help),
414 _ignoreUnmatched(false),
415 _ignoring(false) {
416 _constructor();
417}
418
419inline void CmdLine::_constructor() {
421 _autoArgs._parser = this;
422 _createIgnoreRestArgument();
423 if (_helpAndVersion) _createHelpAndVersionArguments();
424}
425
426inline void CmdLine::_createIgnoreRestArgument() {
427 Visitor *v = new IgnoreRestVisitor(*this);
428 SwitchArg *ignore = new SwitchArg(
430 translateMessage("ignore_rest_description",
431 "Ignores the rest of the labeled arguments following this flag."),
432 false, v);
433 _ignoreArg = ignore;
434 _deleteOnExit(ignore);
435 _deleteOnExit(v);
436 _autoArgs.add(ignore);
437 CmdLine::addToArgList(ignore);
438}
439
440inline void CmdLine::_createHelpAndVersionArguments() {
441 Visitor *v = new HelpVisitor(this, &_output);
442 SwitchArg *help = new SwitchArg(
443 "h", "help",
444 translateMessage("help_description",
445 "Displays usage information and exits."),
446 false, v);
447 _helpArg = help;
448 _deleteOnExit(help);
449 _deleteOnExit(v);
450
451 v = new VersionVisitor(this, &_output);
452 SwitchArg *vers = new SwitchArg(
453 "", "version",
454 translateMessage("version_description",
455 "Displays version information and exits."),
456 false, v);
457 _versionArg = vers;
458 _deleteOnExit(vers);
459 _deleteOnExit(v);
460
461 // Retain the established registration order used by help output.
462 _autoArgs.add(vers);
464 _autoArgs.add(help);
466}
467
468inline void CmdLine::_refreshBuiltinDescriptions() {
469 if (_ignoreArg != NULL) {
471 "ignore_rest_description",
472 "Ignores the rest of the labeled arguments following this flag."));
473 }
474 if (_helpArg != NULL) {
476 "help_description",
477 "Displays usage information and exits."));
478 }
479 if (_versionArg != NULL) {
481 "version_description",
482 "Displays version information and exits."));
483 }
484}
485
486inline void CmdLine::xorAdd(const std::vector<Arg *> &args) {
487 OneOf *group = new OneOf(*this);
488 _deleteOnExit(group);
489
490 for (std::vector<Arg *>::const_iterator it = args.begin(); it != args.end();
491 ++it) {
492 group->add(**it);
493 }
494}
495
496inline void CmdLine::xorAdd(Arg &a, Arg &b) {
497 std::vector<Arg *> ors;
498 ors.push_back(&a);
499 ors.push_back(&b);
500 xorAdd(ors);
501}
502
503// Insertion hooks run against a private list. Bindings are
504// temporarily visible to hooks and restored unless the whole operation commits.
506public:
507 explicit Registration(CmdLine &cmd)
508 : _cmd(cmd), _args(cmd._argList), _numRequired(cmd._numRequired),
509 _hasOptionalUnlabeledArg(cmd._hasOptionalUnlabeledArg), _bindings() {
510 if (_cmd._registrationActive)
511 throw SpecificationException("Argument registration cannot be re-entered");
512 _cmd._registrationActive = true;
513 }
514
515 ~Registration() throw() {
516 for (Bindings::reverse_iterator it = _bindings.rbegin();
517 it != _bindings.rend(); ++it)
518 it->first->_parserDelimiter = it->second;
519 _cmd._registrationActive = false;
520 }
521
522 void add(Arg &arg) {
523 arg._validateAliases(_cmd._delimiter, Arg::flagStartString(),
525 validateConflicts(arg);
526 validatePositionalOrder(arg);
527 _bindings.push_back(std::make_pair(&arg, arg._parserDelimiter));
528 arg._parserDelimiter = &_cmd._delimiter;
529 arg.addToList(_args);
530 if (arg.isRequired()) ++_numRequired;
531 }
532
533 void commit() {
534 _cmd._argList.swap(_args);
535 _cmd._numRequired = _numRequired;
536 _cmd._hasOptionalUnlabeledArg = _hasOptionalUnlabeledArg;
537 _bindings.clear();
538 }
539
540private:
541 void validateConflicts(const Arg &arg) const {
542 for (ArgListIterator it = _args.begin(); it != _args.end(); ++it)
543 if (arg.conflictsWith(**it) ||
544 arg._aliasConflictsWith(**it, Arg::flagStartString(),
546 (*it)->_aliasConflictsWith(arg, Arg::flagStartString(),
549 "Argument with same flag/name already exists!", arg.longID());
550 }
551
552 void validatePositionalOrder(Arg &arg) {
553 if (!arg.hasLabel()) {
554 if (_hasOptionalUnlabeledArg)
556 "You can't specify ANY Unlabeled Arg following an optional "
557 "Unlabeled Arg", arg.longID());
558 if (!arg.isRequired() && !arg.acceptsMultipleValues())
559 _hasOptionalUnlabeledArg = true;
560 }
561 }
562
563 Registration(const Registration &);
564 Registration &operator=(const Registration &);
565 typedef std::vector<std::pair<Arg *, const char *> > Bindings;
566 CmdLine &_cmd;
567 std::list<Arg *> _args;
568 int _numRequired;
569 bool _hasOptionalUnlabeledArg;
570 Bindings _bindings;
571};
572
574 if (group._parser)
575 throw SpecificationException("Arg group can have only one parser");
576 std::list<ArgGroup *> groups(_argGroups);
577 groups.push_back(&group);
578 Registration registration(*this);
579 for (ArgGroup::iterator it = group.begin(); it != group.end(); ++it)
580 registration.add(**it);
581 group._parser = this;
582 _argGroups.swap(groups);
583 registration.commit();
584 return *this;
585}
586
587inline ArgContainer &CmdLine::add(Arg &a) { return add(&a); }
588
589inline void CmdLine::addToArgList(Arg *a) {
590 Registration registration(*this);
591 registration.add(*a);
592 registration.commit();
593}
594
597 members.push_back(a);
598 Registration registration(*this);
599 registration.add(*a);
600 _standaloneArgs._args.swap(members);
601 registration.commit();
602 return *this;
603}
604
605inline void CmdLine::parse(int argc, const char *const *argv) {
606 // this step is necessary so that we have easy access to
607 // mutable strings.
608 std::vector<std::string> args;
609 for (int i = 0; i < argc; i++) args.push_back(argv[i]);
610
611 parse(args);
612}
613
614inline void CmdLine::parse(std::vector<std::string> &args) {
615 bool shouldExit = false;
616 int estat = 0;
617
618 try {
619 _setProgramName(args);
620 const int requiredCount = _parseArguments(args);
621 _validateRequiredArguments(requiredCount);
622 } catch (ArgException &e) {
623 // If we're not handling the exceptions, rethrow.
624 if (!_handleExceptions) {
625 throw;
626 }
627
628 try {
629 _output->failure(*this, e);
630 } catch (ExitException &ee) {
631 estat = ee.getExitStatus();
632 shouldExit = true;
633 }
634 } catch (ExitException &ee) {
635 // If we're not handling the exceptions, rethrow.
636 if (!_handleExceptions) {
637 throw;
638 }
639
640 estat = ee.getExitStatus();
641 shouldExit = true;
642 }
643
644 if (shouldExit) exit(estat);
645}
646
647inline void CmdLine::_setProgramName(std::vector<std::string> &args) {
648 if (args.empty()) {
649 // https://sourceforge.net/p/tclap/bugs/30/
651 "The args vector must not be empty, "
652 "the first entry should contain the "
653 "program's name.");
654 }
655
656 // TODO(macbishop): Maybe store the full name somewhere?
657 _progName = basename(args.front());
658 args.erase(args.begin());
659}
660
661inline int CmdLine::_parseArguments(std::vector<std::string> &args) {
662 int requiredCount = 0;
663 for (int i = 0; static_cast<unsigned int>(i) < args.size(); i++) {
664 bool matched = _processArgument(i, args, requiredCount);
665
666 // checks to see if the argument is an empty combined
667 // switch and if so, then we've actually matched it
668 if (!matched && _emptyCombined(args[i])) matched = true;
669
670 if (!matched && !ignoreRest() && !_ignoreUnmatched)
671 throw(
672 CmdLineParseException("Couldn't find match "
673 "for argument",
674 args[i]));
675 }
676
677 return requiredCount;
678}
679
680inline bool CmdLine::_processArgument(int &index,
681 std::vector<std::string> &args,
682 int &requiredCount) {
683 for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++) {
684 Arg &arg = **it;
685 // Count a required argument only on its first match.
686 bool alreadySet = arg.isSet();
687 bool ignore = arg.isIgnoreable() && ignoreRest();
688 if (!ignore && arg.processArg(&index, args)) {
689 requiredCount += (!alreadySet && arg.isRequired()) ? 1 : 0;
690 return true;
691 }
692 }
693
694 return false;
695}
696
697inline void CmdLine::_validateRequiredArguments(int requiredCount) {
698 std::list<ArgGroup *> missingArgGroups;
699 // Once all arguments have been parsed, check that we don't
700 // violate any constraints.
701 for (std::list<ArgGroup *>::iterator it = _argGroups.begin();
702 it != _argGroups.end(); ++it) {
703 bool missingRequired = (*it)->validate();
704 if (missingRequired) {
705 missingArgGroups.push_back(*it);
706 }
707 }
708
709 if (requiredCount < _numRequired || !missingArgGroups.empty()) {
710 missingArgsException(missingArgGroups);
711 }
712
713 if (requiredCount > _numRequired) {
714 throw(CmdLineParseException(
715 translateMessage("too_many_arguments", "Too many arguments!")));
716 }
717}
718
719inline bool CmdLine::_emptyCombined(const std::string &s) {
720 if (s.length() > 0 && s[0] != Arg::flagStartChar()) return false;
721
722 for (int i = 1; static_cast<unsigned int>(i) < s.length(); i++)
723 if (s[i] != Arg::blankChar()) return false;
724
725 return true;
726}
727
729 const std::list<ArgGroup *> &missing) {
730 int count = 0;
731
732 std::string missingArgList;
733 for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++) {
734 if ((*it)->isRequired() && !(*it)->isSet()) {
735 missingArgList += (*it)->getName();
736 missingArgList += ", ";
737 count++;
738 }
739 }
740
741 for (std::list<ArgGroup *>::const_iterator it = missing.begin();
742 it != missing.end(); it++) {
743 missingArgList += (*it)->getName();
744 missingArgList += ", ";
745 count++;
746 }
747
748 missingArgList = missingArgList.substr(0, missingArgList.length() - 2);
749
750 std::string msg;
751 if (count > 1)
752 msg = translateMessage("required_arguments_missing",
753 "Required arguments missing: ");
754 else
755 msg = translateMessage("required_argument_missing",
756 "Required argument missing: ");
757
758 msg += missingArgList;
759
760 throw(CmdLineParseException(msg));
761}
762
763inline void CmdLine::setOutput(CmdLineOutput *co) { _output = co; }
764
765inline void CmdLine::setExceptionHandling(const bool state) {
766 _handleExceptions = state;
767}
768
769inline void CmdLine::reset() {
770 _ignoring = false;
771 for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++)
772 (*it)->reset();
773
774 _progName.clear();
775}
776
777inline void CmdLine::ignoreUnmatched(const bool ignore) {
778 _ignoreUnmatched = ignore;
779}
780
782// End CmdLine.cpp
784
785} // namespace TCLAP
786
787#endif // TCLAP_CMD_LINE_H
Groups arguments for presentation without imposing a selection rule.
Definition ArgGroup.h:183
Interface that allows adding an Arg to a "container".
A simple class that defines and argument exception.
ArgGroup is the base class for implementing groups of arguments that are mutually exclusive (it repla...
Definition ArgGroup.h:41
CmdLineInterface * _parser
Definition ArgGroup.h:124
iterator begin()
Definition ArgGroup.h:110
std::list< Arg * > Container
Definition ArgGroup.h:45
iterator end()
Definition ArgGroup.h:111
Container _args
Definition ArgGroup.h:125
Container::iterator iterator
Definition ArgGroup.h:46
A virtual base class that defines the essential data for all arguments.
Definition Arg.h:66
static char blankChar()
The char used as a place holder when SwitchArgs are combined.
Definition Arg.h:247
bool isSet() const
Indicates whether the argument has already been set.
Definition Arg.h:751
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
Definition Arg.h:581
static const std::string nameStartString()
Definition Arg.h:275
bool conflictsWith(const Arg &a) const
Checks declared registration conflicts: the same object, the same name, or the same nonempty short fl...
Definition Arg.h:730
static const std::string ignoreNameString()
The name used to identify the ignore rest argument.
Definition Arg.h:280
static char flagStartChar()
Definition Arg.h:256
virtual void addToList(std::list< Arg * > &argList) const
Adds this to the specified list of Args.
Definition Arg.h:809
virtual bool acceptsMultipleValues()
Use by output classes to determine whether an Arg accepts multiple values.
Definition Arg.h:815
virtual bool hasLabel() const
Definition Arg.h:445
virtual bool isRequired() const
Indicates whether the argument is required.
Definition Arg.h:747
virtual void setDescription(const std::string &desc)
Updates the argument description.
Definition Arg.h:333
static const std::string flagStartString()
Definition Arg.h:266
The base class that manages the command line definition and passes along the parsing to the appropria...
The interface that any output object must implement.
virtual void failure(CmdLineInterface &c, ArgException &e)=0
Generates some sort of output for a failure.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
Registration(CmdLine &cmd)
Definition CmdLine.h:507
The base class that manages the command line definition and passes along the parsing to the appropria...
Definition CmdLine.h:85
MessageTranslator * _messageTranslator
Definition CmdLine.h:180
std::list< Arg * > _argList
The list of arguments that will be tested against the command line.
Definition CmdLine.h:91
void setMessageTranslator(const T &translator)
Sets an optional message translator callback.
Definition CmdLine.h:367
SwitchArg * _versionArg
Definition CmdLine.h:188
SwitchArg * _ignoreArg
Built-in arguments whose descriptions may need refreshing when the translator changes.
Definition CmdLine.h:186
bool _emptyCombined(const std::string &s)
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
Definition CmdLine.h:719
void reset()
Allows the CmdLine object to be reused.
Definition CmdLine.h:769
int _numRequired
The number of arguments that are required to be present on the command line.
Definition CmdLine.h:122
std::string _version
The version to be displayed with the –version switch.
Definition CmdLine.h:115
bool _handleExceptions
Should CmdLine handle parsing exceptions internally?
Definition CmdLine.h:159
std::string _message
A message used to describe the program.
Definition CmdLine.h:110
void setOutput(CmdLineOutput *co)
Definition CmdLine.h:763
StandaloneArgs _standaloneArgs
Definition CmdLine.h:93
char getDelimiter() const
Returns the delimiter string.
Definition CmdLine.h:331
CmdLineOutput * _output
Object that handles all output for the CmdLine.
Definition CmdLine.h:154
bool _registrationActive
Definition CmdLine.h:132
char _delimiter
The character that is used to separate the argument flag/name from the value.
Definition CmdLine.h:128
void ignoreUnmatched(const bool ignore)
Allows unmatched args to be ignored.
Definition CmdLine.h:777
void beginIgnoring()
Begin ignoring arguments since the "--" argument was specified.
Definition CmdLine.h:384
std::list< ArgGroup * > _argGroups
Some args have set constraints on them (i.e., exactly or at most one must be specified.
Definition CmdLine.h:100
DeferDelete _deleteOnExit
Add pointers that should be deleted as part of cleanup when this object is destroyed.
Definition CmdLine.h:144
std::string _progName
The name of the program.
Definition CmdLine.h:105
void addToArgList(Arg *a)
Definition CmdLine.h:589
bool hasExceptionHandling() const
Returns the current state of the internal exception handling.
Definition CmdLine.h:348
void setExceptionHandling(const bool state)
Disables or enables CmdLine's internal parsing exception handling.
Definition CmdLine.h:765
std::list< Arg * > getArgList() const
Definition CmdLine.h:324
std::string getMessage() const
Returns the message string.
Definition CmdLine.h:332
StdOutput _defaultOutput
Default output handler if nothing is specified.
Definition CmdLine.h:149
bool attachGroup(ArgGroup &group)
Definition CmdLine.h:134
bool hasHelpAndVersion() const
Indicates whether or not the help and version switches were created automatically.
Definition CmdLine.h:333
std::string translateMessage(const std::string &messageId, const std::string &fallback) const
Translates a built-in message.
Definition CmdLine.h:376
bool ignoreRest()
Whether to ignore the rest.
Definition CmdLine.h:385
SwitchArg * _helpArg
Definition CmdLine.h:187
void missingArgsException(const std::list< ArgGroup * > &missing)
Throws an exception listing the missing args.
Definition CmdLine.h:728
virtual ~CmdLine()
Deletes any resources allocated by a CmdLine object.
Definition CmdLine.h:260
void parse(int argc, const char *const *argv)
Parses the command line.
Definition CmdLine.h:605
std::string getVersion() const
Returns the version string.
Definition CmdLine.h:319
std::string getProgramName() const
Returns the program name string.
Definition CmdLine.h:321
std::list< ArgGroup * > getArgGroups()
Returns the list of ArgGroups.
Definition CmdLine.h:325
ArgContainer & add(Arg &a)
Adds an argument to the list of arguments to be parsed.
Definition CmdLine.h:587
StandaloneArgs _autoArgs
Definition CmdLine.h:94
bool _hasOptionalUnlabeledArg
Definition CmdLine.h:131
void xorAdd(Arg &a, Arg &b)
Definition CmdLine.h:496
DeferDelete can be used by objects that need to allocate arbitrary other objects to live for the dura...
Definition DeferDelete.h:36
ArgContainer & add(Arg &arg)
Add an argument to this arg group.
Definition ArgGroup.h:137
Thrown when TCLAP thinks the program should exit.
int getExitStatus() const
Implements a group of arguments where exactly one must be selected.
Definition ArgGroup.h:169
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
bool showAsGroup() const
If arguments in this group should show up as grouped in help.
Definition CmdLine.h:78
ArgContainer & add(Arg *arg)
Add an argument to this arg group.
Definition CmdLine.h:64
A class that isolates any output from the CmdLine object so that it may be easily modified.
Definition StdOutput.h:48
A simple switch argument.
Definition SwitchArg.h:40
Definition Arg.h:52
std::list< Arg * >::const_iterator ArgListIterator
Typedef of an Arg list iterator.
Definition Arg.h:451
std::string basename(std::string s)
virtual std::string translate(const std::string &messageId, const std::string &fallback) const
Definition CmdLine.h:174
MessageTranslatorImpl(const T &translator)
Definition CmdLine.h:173
Optional callback used to localize user-facing strings.
Definition CmdLine.h:164
virtual std::string translate(const std::string &messageId, const std::string &fallback) const =0