#include <ArArgumentParser.h>
This class is made for parsing arguments from the argv and argc variables passed into a program's main() function by the operating system, from an ArArgumentBuilder object, or just from a string (e.g. provided by WinMain() in a Windows MFC program.)
It will also load default argument values if you call loadDefaultArguments(). Aria::init() adds the file /etc/Aria.args and the environment variable ARIAARGS as locations for argument defaults, so loadDefaultArguments() will always search those. You can use this mechanism to avoid needing to always supply command line parameters to all programs. For example, if you use different serial ports than the defaults for the robot and laser, you can put a -robotPort or -laserPort argument in /etc/Aria.args for all programs that call loadDefaultArguments() to use. You can add other files or environment variables to the list of default argument locations with addDefaultArgumentFile() and addDefaultArgumentEnv().
Note that the wasReallySet behavior has changed. It used to set the variable to false or to true, now it will only set it to false if 'setWasReallySetOnlyTrue' is set to false. By default that is set to false, but you can just set it to true after you make the parser with no ill effects since all of the built in Aria parsers will play nicely with this value, setting it to true or false while they parse but then setting it to whatever it was when they started. This change in behavior is so that checking for two things (like -robotPort and -rp) can work without a lot of extra work.
actionGroupExample.cpp, actsColorFollowingExample.cpp, auxSerialExample.cpp, configExample.cpp, demo.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, moduleExample.cpp, robotConnectionCallbacks.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, teleopActionsExample.cpp, and wander.cpp.
Public Member Functions | |
void | addDefaultArgument (const char *argument, int position=-1) |
Adds a string as a default argument. | |
ArArgumentParser (ArArgumentBuilder *builder) | |
Constructor, takes an argument builder. | |
ArArgumentParser (int *argc, char **argv) | |
Constructor, takes the argc argv. | |
bool | checkArgument (const char *argument) |
Returns true if the argument was found. | |
bool | checkArgumentVar (const char *argument,...) |
Returns true if the argument was found. | |
bool | checkHelpAndWarnUnparsed (unsigned int numArgsOkay=0) |
Checks for the help strings and warns about unparsed arguments. | |
char * | checkParameterArgument (const char *argument, bool returnFirst=false) |
Returns the word/argument after given argument. | |
bool | checkParameterArgumentBool (const char *argument, bool *dest, bool *wasReallySet=NULL, bool returnFirst=false) |
Returns the word/argument after given argument. | |
bool | checkParameterArgumentBoolVar (bool *wasReallySet, bool *dest, const char *argument,...) |
Returns the word/argument after given argument. | |
bool | checkParameterArgumentDouble (const char *argument, double *dest, bool *wasReallySet=NULL, bool returnFirst=false) |
Returns the floating point number after given argument. | |
bool | checkParameterArgumentDoubleVar (bool *wasReallySet, double *dest, const char *argument,...) |
Returns the double after given argument. | |
bool | checkParameterArgumentFloat (const char *argument, float *dest, bool *wasReallySet=NULL, bool returnFirst=false) |
Returns the floating point number after given argument. | |
bool | checkParameterArgumentFloatVar (bool *wasReallySet, float *dest, const char *argument,...) |
Returns the float after given argument. | |
bool | checkParameterArgumentInteger (const char *argument, int *dest, bool *wasReallySet=NULL, bool returnFirst=false) |
Returns the integer after given argument. | |
bool | checkParameterArgumentIntegerVar (bool *wasReallySet, int *dest, const char *argument,...) |
Returns the integer after given argument. | |
bool | checkParameterArgumentString (const char *argument, const char **dest, bool *wasReallySet=NULL, bool returnFirst=false) |
Returns the word/argument after given argument. | |
bool | checkParameterArgumentStringVar (bool *wasReallySet, const char **dest, const char *argument,...) |
Returns the word/argument after given argument. | |
char * | checkParameterArgumentVar (const char *argument,...) |
Returns the word/argument after given argument. | |
const char * | getArg (size_t whichArg) const |
Gets a specific argument. | |
size_t | getArgc (void) const |
Gets how many arguments are left in this parser. | |
char ** | getArgv (void) const |
Gets the argv. | |
const char * | getStartingArguments (void) const |
Gets the arguments this parser started with (if possible, NULL otherwise). | |
bool | getWasReallySetOnlyTrue (void) |
If we only set wasReallySet to true. | |
void | loadDefaultArguments (int positon=1) |
Adds args from default files and environmental variables. | |
void | log (void) const |
Prints out the arguments left in this parser. | |
void | removeArg (size_t which) |
Internal function to remove an argument that was parsed. | |
void | setWasReallySetOnlyTrue (bool wasReallySetOnlyTrue) |
If we should only set wasReallySet to true. | |
~ArArgumentParser () | |
Destructor. | |
Static Public Member Functions | |
static void | addDefaultArgumentEnv (const char *env) |
Adds another file or environmental variable to the list of defaults. | |
static void | addDefaultArgumentFile (const char *file) |
Adds another file or environmental variable to the list of defaults. | |
static void | logDefaultArgumentLocations (void) |
Logs the default argument locations. | |
Protected Attributes | |
int * | myArgc |
char ** | myArgv |
ArArgumentBuilder * | myBuilder |
char | myEmptyArg [1] |
bool | myHelp |
bool | myOwnBuilder |
bool | myReallySetOnlyTrue |
bool | myUsingBuilder |
Static Protected Attributes | |
static std::list< bool > | ourDefaultArgumentLocIsFile |
static std::list< std::string > | ourDefaultArgumentLocs |
|
Constructor, takes the argc argv.
|
|
Constructor, takes an argument builder.
|
|
Adds another file or environmental variable to the list of defaults. This adds an environment variable to the list of default argument locations.
|
|
Adds another file or environmental variable to the list of defaults. This adds a file to the list of default argument locations.
|
|
Returns true if the argument was found.
|
|
Returns true if the argument was found. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Checks for the help strings and warns about unparsed arguments. Check whether a special "help" flag was given in the arguments, and also print a warning (Using ArLog at Normal log level) if any unparsed arguments were found. The following are the help flags: -help, -h, --help, /?, /h.
|
|
Returns the word/argument after given argument.
|
|
Returns the word/argument after given argument. This is like checkParameterArgument but lets you fail out if the argument is there but the parameter for it is not
|
|
Returns the word/argument after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Returns the floating point number after given argument.
|
|
Returns the double after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Returns the floating point number after given argument.
|
|
Returns the float after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Returns the integer after given argument. This is like checkParameterArgument but lets you fail out if the argument is there but the parameter for it is not
|
|
Returns the integer after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Returns the word/argument after given argument. This is like checkParameterArgument but lets you fail out if the argument is there but the parameter for it is not
|
|
Returns the word/argument after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
Returns the word/argument after given argument. Java and Python Wrappers: Not available in Java or Python wrapper libraries. |
|
If we only set wasReallySet to true. See the description for the class for more information about this |
|
Adds args from default files and environmental variables. Search all locations for argument defaults and parse them. These locations may be environment variables to read argument varues from, or files to read.
|
|
If we should only set wasReallySet to true. See the description for the class for more information about this |