| 197 | } |
| 198 | |
| 199 | std::pair<std::string, std::string> Settings::getNameAndVersion(const std::string& productName) { |
| 200 | if (productName.empty()) |
| 201 | return {}; |
| 202 | const std::string::size_type pos1 = productName.rfind(' '); |
| 203 | if (pos1 == std::string::npos) |
| 204 | return {}; |
| 205 | if (pos1 + 2 >= productName.length()) |
| 206 | return {}; |
| 207 | for (auto pos2 = pos1 + 1; pos2 < productName.length(); ++pos2) { |
| 208 | const char c = productName[pos2]; |
| 209 | const char prev = productName[pos2-1]; |
| 210 | if (std::isdigit(c)) |
| 211 | continue; |
| 212 | if (c == '.' && std::isdigit(prev)) |
| 213 | continue; |
| 214 | if (c == 's' && pos2 + 1 == productName.length() && std::isdigit(prev)) |
| 215 | continue; |
| 216 | return {}; |
| 217 | } |
| 218 | return {productName.substr(0, pos1), productName.substr(pos1+1)}; |
| 219 | } |
| 220 | |
| 221 | std::string Settings::parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> &groups) |
| 222 | { |