![]() |
Eclipse 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 (char abbr) |
converts char to string More... | |
static std::string | convert (const char *arg) |
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 46 of file OptionsParser.h.
|
staticprivate |
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 60 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 137 of file OptionsParser.cpp.
References WRITE_ERROR.
Referenced by check().
|
staticprivate |
converts char to string
[in] | abbr | The char to convert |
Definition at line 160 of file OptionsParser.cpp.
|
staticprivate |
Converts char* to string.
[in] | arg | The c-string to convert |
Definition at line 153 of file OptionsParser.cpp.
Referenced by check(), and processNonBooleanSingleSwitch().
|
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 147 of file OptionsParser.cpp.
Referenced by check().
|
static |
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 37 of file OptionsParser.cpp.
References check(), and WRITE_ERROR.
Referenced by OptionsIO::getOptions(), and OptionsIO::loadConfiguration().
|
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 117 of file OptionsParser.cpp.
References convert(), OptionsCont::set(), and WRITE_ERROR.
Referenced by check().