39 for (
int i = 1; i < argc;) {
44 add =
check(argv[i], argv[i + 1], ok);
46 add =
check(argv[i],
nullptr, ok);
50 WRITE_ERROR(
"On processing option '" + std::string(argv[i]) +
"':\n " + e.what());
71 std::string tmp(arg1 + 2);
72 const std::string::size_type idx1 = tmp.find(
'=');
74 if (idx1 != std::string::npos) {
75 ok &= oc.
set(tmp.substr(0, idx1), tmp.substr(idx1 + 1));
77 if (arg2 ==
nullptr || (oc.
isBool(
convert(arg1 + 2)) && arg2[0] ==
'-')) {
87 for (
int i = 1; arg1[i] != 0; i++) {
90 if (arg2 ==
nullptr || arg2[0] ==
'-' || arg1[i + 1] != 0) {
100 if (arg2 ==
nullptr || arg1[i + 1] != 0) {
119 if (strlen(arg) < 3) {
120 WRITE_ERROR(
"Missing value for parameter '" + std::string(arg).substr(0, 1) +
"'.");
123 return oc.
set(
convert(arg[0]), std::string(arg + 2));
126 if (strlen(arg) < 2) {
127 WRITE_ERROR(
"Missing value for parameter '" + std::string(arg) +
"'.");
130 return oc.
set(
convert(arg[0]), std::string(arg + 1));
138 if (arg1[0] !=
'-') {
139 WRITE_ERROR(
"The parameter '" + std::string(arg1) +
"' is not allowed in this context.\n Switch or parameter name expected.");
148 return arg1[1] !=
'-';
A storage for options typed value containers)
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool isBool(const std::string &name) const
Returns the information whether the option is a boolean option.
static OptionsCont & getOptions()
Retrieves the options.
static std::string convert(const char *arg)
Converts char* to string.
static int check(const char *arg1, const char *arg2, bool &ok)
parses the previous arguments
static bool isAbbreviation(const char *arg1)
returns the whether the given token is an abbreviation
static bool checkParameter(const char *arg1)
Returns the whether the given token is an option.
static bool processNonBooleanSingleSwitch(OptionsCont &oc, const char *arg)
Extracts the parameter directly attached to an option.
static bool parse(int argc, char **argv)
Parses the given command line arguments.