* 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 */
| 2759 | * @return true if no errors, false if errors |
| 2760 | */ |
| 2761 | bool ASOptions::parseOptions(vector<string> &optionsVector, const string &errorInfo) |
| 2762 | { |
| 2763 | vector<string>::iterator option; |
| 2764 | string arg, subArg; |
| 2765 | optionErrors.clear(); |
| 2766 | |
| 2767 | for (option = optionsVector.begin(); option != optionsVector.end(); ++option) |
| 2768 | { |
| 2769 | arg = *option; |
| 2770 | |
| 2771 | if (arg.compare(0, 2, "--") == 0) |
| 2772 | parseOption(arg.substr(2), errorInfo); |
| 2773 | else if (arg[0] == '-') |
| 2774 | { |
| 2775 | size_t i; |
| 2776 | |
| 2777 | for (i = 1; i < arg.length(); ++i) |
| 2778 | { |
| 2779 | if (i > 1 |
| 2780 | && isalpha((unsigned char)arg[i]) |
| 2781 | && arg[i - 1] != 'x') |
| 2782 | { |
| 2783 | // parse the previous option in subArg |
| 2784 | parseOption(subArg, errorInfo); |
| 2785 | subArg = ""; |
| 2786 | } |
| 2787 | // append the current option to subArg |
| 2788 | subArg.append(1, arg[i]); |
| 2789 | } |
| 2790 | // parse the last option |
| 2791 | parseOption(subArg, errorInfo); |
| 2792 | subArg = ""; |
| 2793 | } |
| 2794 | else |
| 2795 | { |
| 2796 | parseOption(arg, errorInfo); |
| 2797 | subArg = ""; |
| 2798 | } |
| 2799 | } |
| 2800 | if (optionErrors.str().length() > 0) |
| 2801 | return false; |
| 2802 | return true; |
| 2803 | } |
| 2804 | |
| 2805 | void ASOptions::parseOption(const string &arg, const string &errorInfo) |
| 2806 | { |
no outgoing calls
no test coverage detected