24 #ifndef TCLAP_CMDLINE_H
25 #define TCLAP_CMDLINE_H
53 template<
typename T>
void DelPtr(T ptr)
60 typedef typename C::value_type value_type;
61 std::for_each(c.begin(), c.end(), DelPtr<value_type>);
178 bool _helpAndVersion;
194 CmdLine(
const std::string& message,
195 const char delimiter =
' ',
196 const std::string& version =
"none",
197 bool helpAndVersion =
true);
229 void xorAdd( std::vector<Arg*>& xors );
236 void parse(
int argc,
const char *
const * argv);
243 void parse(std::vector<std::string>& args);
319 const std::string& v,
321 : _progName(
"not_set_yet"),
326 _handleExceptions(true),
327 _userSetOutput(false),
328 _helpAndVersion(help)
338 if ( !_userSetOutput ) {
344 inline void CmdLine::_constructor()
352 if ( _helpAndVersion )
356 "Displays usage information and exits.",
364 "Displays version information and exits.",
371 v =
new IgnoreRestVisitor();
374 "Ignores the rest of the labeled arguments following this flag.",
387 (*it)->forceRequired();
388 (*it)->setRequireLabel(
"OR required" );
396 std::vector<Arg*> ors;
412 "Argument with same flag/name already exists!",
426 std::vector<std::string> args;
427 for (
int i = 0; i < argc; i++)
428 args.push_back(argv[i]);
435 bool shouldExit =
false;
440 args.erase(args.begin());
442 int requiredCount = 0;
444 for (
int i = 0;
static_cast<unsigned int>(i) < args.size(); i++) {
445 bool matched =
false;
448 if ( (*it)->processArg( &i, args ) )
504 for (
int i = 1;
static_cast<unsigned int>(i) < s.length(); i++ )
515 std::string missingArgList;
518 if ( (*it)->isRequired() && !(*it)->isSet() )
520 missingArgList += (*it)->getName();
521 missingArgList +=
", ";
525 missingArgList = missingArgList.substr(0,missingArgList.length()-2);
529 msg =
"Required arguments missing: ";
531 msg =
"Required argument missing: ";
533 msg += missingArgList;
555 _userSetOutput =
true;
591 return _helpAndVersion;