#include <ArgumentParser.h>

Public Member Functions | |
| ArgumentParser (const string &helpstr="", char hlpShrt='h', const string &hlpLng="help") | |
| Constructor using a global help string. | |
| ArgumentParser (std::vector< std::string > *files, const string &helpstr="", char hlpShrt='h', const string &hlpLng="help") | |
| Constructor using a global help string and a list of filenames. | |
| ~ArgumentParser () | |
| Constructor using a global help string. | |
| template<class T > | |
| ArgumentParser & | option (T *ptr, char sho, const char *lon, const char *help) |
| Declare an optional argument. | |
| template<class T > | |
| ArgumentParser & | parameter (T *ptr, char sho, const char *lon, const char *help) |
| Declare a mandatory argument. | |
| void | operator() (int argc, char **argv) |
| Parse a command line. | |
| void | operator() (std::list< std::string > str) |
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. | |
| std::vector< std::string > * | files |
| Set of remaining file. | |
| string | globalHelp |
| Overall presentation. | |
| char | helpShortName |
| short name for help | |
| string | helpLongName |
| long name for help | |
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 226 of file ArgumentParser.h.
typedef std::vector<ArgumentBase*> sofa::helper::ArgumentParser::ArgVec [private] |
typedef std::map< string, ArgumentBase* > sofa::helper::ArgumentParser::Map [private] |
typedef std::map<ArgumentBase*,bool> sofa::helper::ArgumentParser::SetMap [private] |
Associate name with boolean value (true iff it is set).
Definition at line 237 of file ArgumentParser.h.
typedef std::string sofa::helper::ArgumentParser::string [private] |
| ArgumentParser::ArgumentParser | ( | std::vector< std::string > * | files, | |
| const string & | helpstr = "", |
|||
| char | hlpShrt = 'h', |
|||
| const string & | hlpLng = "help" | |||
| ) |
Constructor using a global help string and a list of filenames.
Definition at line 73 of file ArgumentParser.cpp.
| ArgumentParser::~ArgumentParser | ( | ) |
Constructor using a global help string.
Definition at line 81 of file ArgumentParser.cpp.
References commands.
| void ArgumentParser::operator() | ( | std::list< std::string > | str | ) |
Definition at line 99 of file ArgumentParser.cpp.
References commands, files, globalHelp, helpLongName, helpShortName, longName, parameter_set, and shortName.
| void ArgumentParser::operator() | ( | int | argc, | |
| char ** | argv | |||
| ) |
Parse a command line.
| argc | number of arguments + 1, as usual in C | |
| argv | arguments | |
| argc | number of arguments + 1, as usual in C | |
| argv | arguments |
Definition at line 91 of file ArgumentParser.cpp.
| ArgumentParser& sofa::helper::ArgumentParser::option | ( | T * | ptr, | |
| char | sho, | |||
| const char * | lon, | |||
| const char * | help | |||
| ) | [inline] |
Declare an optional argument.
| ptr | pointer to the variable | |
| sho | short name | |
| lon | long name | |
| help |
Definition at line 273 of file ArgumentParser.h.
References commands, helpLongName, helpShortName, longName, and shortName.
Referenced by main().
| ArgumentParser& sofa::helper::ArgumentParser::parameter | ( | T * | ptr, | |
| char | sho, | |||
| const char * | lon, | |||
| const char * | help | |||
| ) | [inline] |
Declare a mandatory argument.
| ptr | pointer to the variable | |
| sho | short name | |
| lon | long name | |
| help |
Definition at line 310 of file ArgumentParser.h.
References commands, helpLongName, helpShortName, longName, and shortName.
ArgVec sofa::helper::ArgumentParser::commands [private] |
Set of commands.
Definition at line 245 of file ArgumentParser.h.
Referenced by operator()(), option(), parameter(), and ~ArgumentParser().
std::vector<std::string>* sofa::helper::ArgumentParser::files [private] |
long name for help
Definition at line 253 of file ArgumentParser.h.
Referenced by operator()(), option(), and parameter().
char sofa::helper::ArgumentParser::helpShortName [private] |
short name for help
Definition at line 252 of file ArgumentParser.h.
Referenced by operator()(), option(), and parameter().
Map sofa::helper::ArgumentParser::longName [private] |
long name -> Argument object
Definition at line 234 of file ArgumentParser.h.
Referenced by operator()(), option(), and parameter().
Set map (bool true iff parameter is set).
Definition at line 240 of file ArgumentParser.h.
Referenced by operator()().
std::map< char, ArgumentBase* > sofa::helper::ArgumentParser::shortName [private] |
short name -> Argument object
Definition at line 232 of file ArgumentParser.h.
Referenced by operator()(), option(), and parameter().
1.5.7.1