MCPcopy Create free account
hub / github.com/chrxh/alien / getVersionParts

Method getVersionParts

source/Base/VersionParserService.cpp:36–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36VersionParserService::VersionParts VersionParserService::getVersionParts(std::string const& versionString)
37{
38 if (versionString.empty()) {
39 return VersionParts();
40 }
41
42 std::vector<std::string> versionParts;
43 boost::split(versionParts, versionString, boost::is_any_of("."));
44 VersionParts result{
45 .major = std::stoi(versionParts.at(0)),
46 .minor = std::stoi(versionParts.at(1)),
47 };
48
49 if (versionParts.size() == 3) {
50 result.patch = std::stoi(versionParts.at(2));
51 result.versionType = VersionType_Release;
52 }
53 if (versionParts.size() == 5) {
54 result.patch = 0;
55 if (versionParts.at(3) == "alpha") {
56 result.versionType = VersionType_Alpha;
57 } else if (versionParts.at(3) == "beta") {
58 result.versionType = VersionType_Beta;
59 } else {
60 throw std::runtime_error("Unexpected version number.");
61 }
62 result.preRelease = std::stoi(versionParts.at(4));
63 }
64 return result;
65}
66
67bool VersionParserService::isVersionOutdated(std::string const& otherVersionString)
68{

Calls 3

VersionPartsClass · 0.85
splitFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected