MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getNameAndVersion

Method getNameAndVersion

lib/settings.cpp:199–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199std::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
221std::string Settings::parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> &groups)
222{

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected