AnimaL |
Tutorial |
Documentation |
#include <argumentParser.h>
This object parses arguments from a command line or from an input stream. The arguments are described using a pointer, a short name, a long name and a help message. Mandatory arguments are declared using method "parameter", optional arguments are declared using method "option". Once all arguments declared, operator () does the parsing. The special option -h or --help displays help on all arguments. See examples argumentParserLine_test.cpp and argumentParserFile_test.cpp
Definition at line 150 of file argumentParser.h.
Public Member Functions | |
ArgumentParser (const string &helpstr="", char hlpShrt='h', const string &hlpLng="help") | |
Constructor using a global help string. | |
template<class T> ArgumentParser & | option (T *ptr, char sho, char *lon, char *help) |
Declare an optional argument. | |
template<class T> ArgumentParser & | parameter (T *ptr, char sho, char *lon, char *help) |
Declare a mandatory argument. | |
void | operator() (int argc, char **argv) |
Parse a command line. | |
void | operator() (std::istream &str) |
Parse an input stream. | |
Private Types | |
typedef std::string | string |
String. | |
typedef std::map< string, ArgumentBase * > | Map |
Associate a string with a Argument object. | |
typedef std::map< ArgumentBase *, bool > | SetMap |
Associate name with boolean value (true iff it is set). | |
typedef std::vector< ArgumentBase * > | ArgVec |
Set of commands. | |
Private Attributes | |
std::map< char, ArgumentBase * > | shortName |
short name -> Argument object | |
Map | longName |
long name -> Argument object | |
SetMap | parameter_set |
Set map (bool true iff parameter is set). | |
ArgVec | commands |
Set of commands. | |
string | globalHelp |
Overall presentation. | |
char | helpShortName |
short name for help | |
string | helpLongName |
long name for help |
|
Set of commands.
Definition at line 167 of file argumentParser.h. |
|
Associate a string with a Argument object.
Definition at line 154 of file argumentParser.h. |
|
Associate name with boolean value (true iff it is set).
Definition at line 161 of file argumentParser.h. |
|
String.
Definition at line 152 of file argumentParser.h. Referenced by operator()(). |
|
Constructor using a global help string.
Definition at line 179 of file argumentParser.h. References globalHelp, helpLongName, and helpShortName. |
|
Parse an input stream.
Definition at line 278 of file argumentParser.h. References commands, globalHelp, helpLongName, helpShortName, and parameter_set. |
|
Parse a command line.
Definition at line 264 of file argumentParser.h. References animal::istrstream, and string. |
|
Declare an optional argument.
Definition at line 192 of file argumentParser.h. References commands, helpLongName, and helpShortName. |
|
Declare a mandatory argument.
Definition at line 229 of file argumentParser.h. References commands, helpLongName, and helpShortName. |
|
Set of commands.
Definition at line 169 of file argumentParser.h. Referenced by operator()(), option(), and parameter(). |
|
Overall presentation.
Definition at line 172 of file argumentParser.h. Referenced by ArgumentParser(), and operator()(). |
|
long name for help
Definition at line 174 of file argumentParser.h. Referenced by ArgumentParser(), operator()(), option(), and parameter(). |
|
short name for help
Definition at line 173 of file argumentParser.h. Referenced by ArgumentParser(), operator()(), option(), and parameter(). |
|
long name -> Argument object
Definition at line 158 of file argumentParser.h. |
|
Set map (bool true iff parameter is set).
Definition at line 164 of file argumentParser.h. Referenced by operator()(). |
|
short name -> Argument object
Definition at line 156 of file argumentParser.h. |