15 #ifndef TCLAP_CMDLINE_H 16 #define TCLAP_CMDLINE_H 49 class CmdLine :
public CmdLineInterface
162 CmdLine(
const std::string& message,
163 const char delimiter =
' ',
164 const std::string& version =
"none",
165 bool helpAndVersion =
true);
190 void xorAdd( Arg& a, Arg& b );
197 void xorAdd( std::vector<Arg*>& xors );
204 void parse(
int argc,
char** argv);
259 const std::string& v,
301 v =
new HelpVisitor(
this, &
_output );
302 SwitchArg*
help =
new SwitchArg(
"h",
"help",
303 "Displays usage information and exits.",
309 v =
new VersionVisitor(
this, &
_output );
310 SwitchArg* vers =
new SwitchArg(
"",
"version",
311 "Displays version information and exits.",
318 v =
new IgnoreRestVisitor();
321 "Ignores the rest of the labeled arguments following this flag.",
334 (*it)->forceRequired();
335 (*it)->setRequireLabel(
"OR required" );
343 std::vector<Arg*> ors;
358 throw( SpecificationException(
359 "Argument with same flag/name already exists!",
364 if ( a->isRequired() )
375 std::vector<std::string>
args;
376 for (
int i = 1; i < argc; i++)
377 args.push_back(argv[i]);
379 int requiredCount = 0;
381 for (
int i = 0;
static_cast<unsigned int>(i) < args.size(); i++)
383 bool matched =
false;
386 if ( (*it)->processArg( &i, args ) )
400 throw(CmdLineParseException(
"Couldn't find match for argument",
405 throw(CmdLineParseException(
"One or more required arguments missing!"));
408 throw(CmdLineParseException(
"Too many arguments!"));
410 }
catch ( ArgException e ) {
_output->
failure(*
this,e); exit(1); }
418 for (
int i = 1;
static_cast<unsigned int>(i) < s.length(); i++ )
static char flagStartChar()
std::list< Visitor * >::iterator VisitorListIterator
std::list< Arg * > _argList
std::list< Arg * >::iterator ArgListIterator
static std::string ignoreNameString()
CmdLineOutput * getOutput()
std::string & getVersion()
static std::string flagStartString()
std::vector< Arg * >::iterator ArgVectorIterator
CmdLine(const std::string &message, const char delimiter= ' ', const std::string &version="none", bool helpAndVersion=true)
virtual void failure(CmdLineInterface &c, ArgException &e)=0
static void setDelimiter(char c)
std::string & getProgramName()
std::list< Visitor * > _visitorDeleteOnExitList
XorHandler & getXorHandler()
std::list< Arg * > _argDeleteOnExitList
bool _emptyCombined(const std::string &s)
void deleteOnExit(Arg *ptr)
std::list< Arg * > & getArgList()
void parse(int argc, char **argv)
std::string & getMessage()
void xorAdd(Arg &a, Arg &b)
void setOutput(CmdLineOutput *co)
void add(std::vector< Arg * > &ors)