#include <OptionParser.h>
Public Member Functions | |
OptionParser (const char *progname) | |
Constructor: expects a string containing the name of the calling program. | |
bool | addOption (char sn, const char *ln, const char *hm, bool hasArg=false) |
Add a new option to the list. | |
bool | removeOption (const char *ln) |
Remove an option from the list. | |
int | findOption (const char *ln, bool shortName=false) const |
Find the option in the list. | |
int | addArgument (const char *name, const char *help, bool mandatory=true) |
Add a new argument to the argumet list. | |
void | clearArguments () |
Clear the argument list. | |
bool | parse (int argc, const char **argv, StringMap &opts, ArrayList &args) |
Parse the command line. | |
void | usage () |
Print the usage message. | |
const StringBuffer & | getErrMsg () const |
get error message as a StringBuffer | |
const StringBuffer & | getProgramName () const |
bool OptionParser::addOption | ( | char | sn, | |
const char * | ln, | |||
const char * | hm, | |||
bool | hasArg = false | |||
) |
Add a new option to the list.
sn | the short name of the option (one letter) ln the long name of the option | |
hm | an help message (one line) true if the option requires an argument (default=false) |
bool OptionParser::removeOption | ( | const char * | ln | ) |
Remove an option from the list.
ln | the long name of the option to remove |
int OptionParser::findOption | ( | const char * | ln, | |
bool | shortName = false | |||
) | const |
Find the option in the list.
ln | the long name of the option to remove |
int OptionParser::addArgument | ( | const char * | name, | |
const char * | help, | |||
bool | mandatory = true | |||
) |
Add a new argument to the argumet list.
name | the name of the argument | |
help | an help message true if the option argument is mandatory (default=true) |
bool OptionParser::parse | ( | int | argc, | |
const char ** | argv, | |||
StringMap & | opts, | |||
ArrayList & | args | |||
) |
Parse the command line.
argc | the argc parameter, same as the one of the main() function | |
argv | the argv parameter, same as the one of the main() function | |
OUT | an ArrayList of KeyValuePair containing the options found on the commandline | |
OUT | an ArrayList of StringBuffer containing the other arguments found on the commandline |