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

Method isVersionValid

source/Base/VersionParserService.cpp:13–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "Base/Resources.h"
12
13bool VersionParserService::isVersionValid(std::string const& otherVersionString)
14{
15 try {
16 std::vector<std::string> versionParts;
17 boost::split(versionParts, otherVersionString, boost::is_any_of("."));
18 if (versionParts.size() != 3 && versionParts.size() != 5) {
19 return false;
20 }
21 for (auto const& versionPart : versionParts | boost::adaptors::sliced(0, 3)) {
22 static_cast<void>(std::stoi(versionPart));
23 }
24 if (versionParts.size() == 5) {
25 if (versionParts[3] != "alpha" && versionParts[3] != "beta") {
26 return false;
27 }
28 static_cast<void>(std::stoi(versionParts[4]));
29 }
30 } catch (...) {
31 return false;
32 }
33 return true;
34}
35
36VersionParserService::VersionParts VersionParserService::getVersionParts(std::string const& versionString)
37{

Callers 1

Calls 2

splitFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected