* Parse the opt at a given index, and put it into the opts maps. * * An opt can has the following form: * 1) -keyName=value or --keyName=value (ex. -n=10 --test-count=20) * 2) -keyName value or --keyName value (ex. -n 10 --test-count 20) * 3) -kNumval or --kNumval (ex. -n10 --t20) * 4) -boolProperty or --boolProperty (ex. -sorted --tree-only) * * Only the s
| 5353 | * TODO. Please refer to the implementation to see how the code handles the 3rd and 4th forms separately. |
| 5354 | */ |
| 5355 | size_t parseOpt(size_t argc, char *argv[], size_t index, std::map<std::string, TestlibOpt> &opts) { |
| 5356 | if (index >= argc) |
| 5357 | return 0; |
| 5358 | |
| 5359 | size_t type = getOptType(argv[index]), inc = 1; |
| 5360 | if (type > 0) { |
| 5361 | std::string key(argv[index] + type), val; |
| 5362 | size_t sep = key.find('='); |
| 5363 | if (sep != std::string::npos) { |
| 5364 | val = key.substr(sep + 1); |
| 5365 | key = key.substr(0, sep); |
| 5366 | } else { |
| 5367 | if (index + 1 < argc && getOptType(argv[index + 1]) == 0) { |
| 5368 | val = argv[index + 1]; |
| 5369 | inc = 2; |
| 5370 | } else { |
| 5371 | if (key.length() > 1 && isdigit(key[1])) { |
| 5372 | val = key.substr(1); |
| 5373 | key = key.substr(0, 1); |
| 5374 | } else { |
| 5375 | val = "true"; |
| 5376 | } |
| 5377 | } |
| 5378 | } |
| 5379 | opts[key].value = val; |
| 5380 | } else { |
| 5381 | return inc; |
| 5382 | } |
| 5383 | |
| 5384 | return inc; |
| 5385 | } |
| 5386 | |
| 5387 | /** |
| 5388 | * Global list containing all the arguments in the order given in the command line. |
no test coverage detected