| 158 | // OPTION LIBRARY |
| 159 | |
| 160 | OptionScheme::Args OptionName::DetermineTypeFromHelpText(const std::string& helptext) |
| 161 | { |
| 162 | if (helptext.empty()) |
| 163 | return OptionScheme::ARG_NONE; |
| 164 | |
| 165 | if (helptext[0] == '<') |
| 166 | { |
| 167 | // If the argument is <one-argument>, then it's ARG_NONE. |
| 168 | // If it's <multiple-arguments...>, then it's ARG_VAR. |
| 169 | // When closing angle bracket isn't found, fallback to ARG_ONE. |
| 170 | size_t pos = helptext.find('>'); |
| 171 | if (pos == std::string::npos) |
| 172 | return OptionScheme::ARG_ONE; // mistake, but acceptable |
| 173 | |
| 174 | if (pos >= 4 && helptext.substr(pos-3, 4) == "...>") |
| 175 | return OptionScheme::ARG_VAR; |
| 176 | |
| 177 | // We have < and > without ..., simply one argument |
| 178 | return OptionScheme::ARG_ONE; |
| 179 | } |
| 180 | |
| 181 | if (helptext[0] == '[') |
| 182 | { |
| 183 | // Argument in [] means it is optional; in this case |
| 184 | // you should state that the argument can be given or not. |
| 185 | return OptionScheme::ARG_VAR; |
| 186 | } |
| 187 | |
| 188 | // Also as fallback |
| 189 | return OptionScheme::ARG_NONE; |
| 190 | } |
| 191 | |
| 192 | options_t ProcessOptions(char* const* argv, int argc, std::vector<OptionScheme> scheme) |
| 193 | { |