Parse a command line as specified by its argument vector. No validation occurs and only argument value exceptions are raised, but assignments are made to bound variables where possible. \param s List of strings that constitute the argument list. */
| 1194 | \param s List of strings that constitute the argument list. |
| 1195 | */ |
| 1196 | void parseSimple(std::vector<std::string>& s) |
| 1197 | { |
| 1198 | ArgValList vals(s); |
| 1199 | |
| 1200 | for (size_t i = 0; i < vals.size();) |
| 1201 | { |
| 1202 | const std::string& arg = vals[i]; |
| 1203 | // This may be the value, or it may not. We're passing it along |
| 1204 | // just in case. If there is no value, pass along "" to make |
| 1205 | // clear that there is none. |
| 1206 | std::string value((i != vals.size() - 1) ? vals[i + 1] : ""); |
| 1207 | try |
| 1208 | { |
| 1209 | int matched = parseArg(arg, value); |
| 1210 | if (!matched) |
| 1211 | i++; |
| 1212 | else |
| 1213 | while (matched--) |
| 1214 | vals.consume(i++); |
| 1215 | } |
| 1216 | catch (arg_val_error&) |
| 1217 | { |
| 1218 | throw; |
| 1219 | } |
| 1220 | catch (arg_error&) |
| 1221 | { |
| 1222 | i++; |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | // Go through args and assign those unset to items from the command |
| 1227 | // line not already consumed. |
| 1228 | for (auto ai = m_args.begin(); ai != m_args.end(); ++ai) |
| 1229 | { |
| 1230 | Arg *arg = ai->get(); |
| 1231 | try |
| 1232 | { |
| 1233 | arg->assignPositional(vals); |
| 1234 | } |
| 1235 | catch (arg_val_error&) |
| 1236 | { |
| 1237 | throw; |
| 1238 | } |
| 1239 | catch (arg_error&) |
| 1240 | {} |
| 1241 | } |
| 1242 | s = vals.unconsumedArgs(); |
| 1243 | } |
| 1244 | |
| 1245 | /** |
| 1246 | Parse a command line as specified by its argument list. Parsing |