Mercurial > irccd
diff common/options.cpp @ 23:03068f5ed79d
Misc: various style issues, #419
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 14 Feb 2016 16:15:48 +0100 |
parents | 1158cffe5a5e |
children |
line wrap: on
line diff
--- a/common/options.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/options.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -54,15 +54,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -86,15 +84,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -120,16 +116,14 @@ auto arg = std::string{'-'} + value[i]; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); if (opt->second) { if (i == (len - 1)) { /* End of string, get the next argument (see 2.) */ - if (++it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (++it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it)); toremove += 1; @@ -157,15 +151,13 @@ auto end = args.end(); while (it != end) { - if (!isOption(*it)) { + if (!isOption(*it)) break; - } - if (isLongOption(*it)) { + if (isLongOption(*it)) parseLongOption(result, args, it, end, definition); - } else { + else parseShortOption(result, args, it, end, definition); - } } return result; @@ -175,9 +167,8 @@ { std::vector<std::string> args; - for (int i = 0; i < argc; ++i) { + for (int i = 0; i < argc; ++i) args.push_back(argv[i]); - } auto before = args.size(); auto result = read(args, definition);