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,
   277         for( argIter = _argDeleteOnExitList.begin();
   278                  argIter != _argDeleteOnExitList.end();
   282         for( visIter = _visitorDeleteOnExitList.begin();
   283                  visIter != _visitorDeleteOnExitList.end();
   287         if ( !_userSetOutput )
   293         _output = 
new StdOutput;
   299         if ( _helpAndVersion )
   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.",
   324         deleteOnExit(ignore);
   330         _xorHandler.add( ors );
   334                 (*it)->forceRequired();
   335                 (*it)->setRequireLabel( 
"OR required" );
   343     std::vector<Arg*> ors;
   356         for( 
ArgListIterator it = _argList.begin(); it != _argList.end(); it++ )
   358                         throw( SpecificationException(
   359                                 "Argument with same flag/name already exists!",
   362         a->addToList( _argList );
   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;
   384                 for (
ArgListIterator it = _argList.begin(); it != _argList.end(); it++)
   386                         if ( (*it)->processArg( &i, args ) )
   388                                 requiredCount += _xorHandler.check( *it );
   396                 if ( !matched && _emptyCombined( args[i] ) )
   400                         throw(CmdLineParseException(
"Couldn't find match for argument",
   404         if ( requiredCount < _numRequired )
   405                 throw(CmdLineParseException(
"One or more required arguments missing!"));
   407         if ( requiredCount > _numRequired )
   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++ )
   427         _argDeleteOnExitList.push_back(ptr);
   432         _visitorDeleteOnExitList.push_back(ptr);
   442         _userSetOutput = 
true;
   478         return _helpAndVersion;
 
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)
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)