# HG changeset patch # User David Demelier # Date 1453920790 -3600 # Node ID d8ed4da7688c799f6e1a7464ffb004058426971e # Parent ff8f817755644d200eb8759468b4759c64626d63 Options: new braces style diff -r ff8f81775564 -r d8ed4da7688c modules/options/options.cpp --- a/modules/options/options.cpp Wed Jan 27 19:45:19 2016 +0100 +++ b/modules/options/options.cpp Wed Jan 27 19:53:10 2016 +0100 @@ -52,15 +52,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { + if (opt == definition.end()) throw InvalidOption{arg}; - } /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { + if (it == end || isOption(*it)) throw MissingValue{arg}; - } result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -84,15 +82,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { + if (opt == definition.end()) throw InvalidOption{arg}; - } /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { + if (it == end || isOption(*it)) throw MissingValue{arg}; - } result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -118,16 +114,14 @@ auto arg = std::string{'-'} + value[i]; auto opt = definition.find(arg); - if (opt == definition.end()) { + 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)) { + if (++it == end || isOption(*it)) throw MissingValue{arg}; - } result.insert(std::make_pair(arg, *it)); toremove += 1; @@ -155,15 +149,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; @@ -173,9 +165,8 @@ { std::vector 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);