* parse the options vector * optionsVector can be either a fileOptionsVector (options file) or an optionsVector (command line) * * @return true if no errors, false if errors */
| 2415 | * @return true if no errors, false if errors |
| 2416 | */ |
| 2417 | bool ASOptions::parseOptions(vector<string> &optionsVector, const string& errorInfo) |
| 2418 | { |
| 2419 | vector<string>::iterator option; |
| 2420 | string arg, subArg; |
| 2421 | optionErrors.clear(); |
| 2422 | |
| 2423 | for (option = optionsVector.begin(); option != optionsVector.end(); ++option) |
| 2424 | { |
| 2425 | arg = *option; |
| 2426 | |
| 2427 | if (arg.compare(0, 2, "--") == 0) |
| 2428 | parseOption(arg.substr(2), errorInfo); |
| 2429 | else if (arg[0] == '-') |
| 2430 | { |
| 2431 | size_t i; |
| 2432 | |
| 2433 | for (i = 1; i < arg.length(); ++i) |
| 2434 | { |
| 2435 | if (i > 1 |
| 2436 | && isalpha(arg[i]) |
| 2437 | && arg[i-1] != 'x') |
| 2438 | { |
| 2439 | // parse the previous option in subArg |
| 2440 | parseOption(subArg, errorInfo); |
| 2441 | subArg = ""; |
| 2442 | } |
| 2443 | // append the current option to subArg |
| 2444 | subArg.append(1, arg[i]); |
| 2445 | } |
| 2446 | // parse the last option |
| 2447 | parseOption(subArg, errorInfo); |
| 2448 | subArg = ""; |
| 2449 | } |
| 2450 | else |
| 2451 | { |
| 2452 | parseOption(arg, errorInfo); |
| 2453 | subArg = ""; |
| 2454 | } |
| 2455 | } |
| 2456 | if (optionErrors.str().length() > 0) |
| 2457 | return false; |
| 2458 | return true; |
| 2459 | } |
| 2460 | |
| 2461 | void ASOptions::parseOption(const string& arg, const string& errorInfo) |
| 2462 | { |