SUMO - Simulation of Urban MObility
|
Parses command line arguments. More...
#include <OptionsParser.h>
Static Public Member Functions | |
static bool | parse (int argc, char **argv) |
Parses the given command line arguments. More... | |
Static Private Member Functions | |
static int | check (const char *arg1, const char *arg2, bool &ok) |
parses the previous arguments More... | |
static bool | checkParameter (const char *arg1) |
Returns the whether the given token is an option. More... | |
static std::string | convert (const char *arg) |
Converts char* to string. More... | |
static std::string | convert (char abbr) |
converts char to string More... | |
static bool | isAbbreviation (const char *arg1) |
returns the whether the given token is an abbreviation More... | |
static bool | processNonBooleanSingleSwitch (OptionsCont &oc, const char *arg) |
Extracts the parameter directly attached to an option. More... | |
Parses command line arguments.
The only public method parses the given list of arguments. It returns false when something failed. This may happen if the syntax of the arguments is invalid, a value is tried to be set several times or an unknown option is tried to be set.
The class assumes all options are unset or using default values only.
Definition at line 56 of file OptionsParser.h.
parses the previous arguments
[in] | arg1 | The first token to parse |
[in] | arg2 | The second token to parse, 0 if there is none |
[in,out] | ok | Whether the parsing was successfull |
InvalidArgument | If a performed setting of an option failed (see Option::set) |
Definition at line 78 of file OptionsParser.cpp.
References checkParameter(), convert(), OptionsCont::getOptions(), isAbbreviation(), OptionsCont::isBool(), processNonBooleanSingleSwitch(), and OptionsCont::set().
Referenced by parse().
|
staticprivate |
Returns the whether the given token is an option.
The given token is assumed to be an option if it starts with a '-'.
[in] | arg1 | The token to check |
Definition at line 155 of file OptionsParser.cpp.
References WRITE_ERROR.
Referenced by check().
|
staticprivate |
Converts char* to string.
[in] | arg | The c-string to convert |
Definition at line 171 of file OptionsParser.cpp.
Referenced by check(), and processNonBooleanSingleSwitch().
|
staticprivate |
converts char to string
[in] | abbr | The char to convert |
Definition at line 178 of file OptionsParser.cpp.
|
staticprivate |
returns the whether the given token is an abbreviation
The given token is assumed to be an option if it starts with two '-'.
[in] | arg1 | The token to check |
Definition at line 165 of file OptionsParser.cpp.
Referenced by check().
Parses the given command line arguments.
[in] | oc | The options container to fill |
[in] | argc | The number of given command line arguments |
[in] | argv | The command line arguments |
InvalidArgument | If a performed setting of an option failed (see Option::set) |
Definition at line 50 of file OptionsParser.cpp.
References check(), and WRITE_ERROR.
Referenced by OptionsIO::getOptions().
|
staticprivate |
Extracts the parameter directly attached to an option.
Parses single tokens which contain an option and the parameter (like -c=myconfig.cfg)
[in] | oc | The container to store the result into |
[in] | arg | The token to parse |
InvalidArgument | If a performed setting of an option failed (see Option::set) |
Definition at line 135 of file OptionsParser.cpp.
References convert(), OptionsCont::set(), and WRITE_ERROR.
Referenced by check().