MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / toUInt

Method toUInt

src/frameworks/UBVersion.cpp:43–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43uint UBVersion::toUInt() const
44{
45 /* Based on semantic versioning, version numbers look like:
46 * Major.Minor.Patch-Type.Build
47 *
48 * To compare version numbers, the string is split into each part, and they are multiplied
49 * to give a number where the first two digits are the Major version, the next two are the
50 * Minor version, and so on.
51 *
52 * i.e if Major, Minor etc. are named A, B, C, D, E, the number will look like:
53 * AABBCCDDEE
54 */
55
56 uint result = 0;
57 static const QRegularExpression minusOrDot("[-\\.]");
58 QStringList list = mString.split(minusOrDot);
59 switch (list.count()) {
60 case 2:
61 //short version 1.0
62 result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + (Release * 100);
63 break;
64 case 3:
65 //release version 1.0.0
66 result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + list.at(2).toUInt()*10000 + (Release * 100);
67 break;
68 case 5:{
69 //standard version 1.0.0.a/b/rc.0
70 uint releaseStage = list.at(3).startsWith("a") ? Alpha :(list.at(3).startsWith("b") ? Beta : ReleaseCandidate);
71 result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + (list.at(2).toUInt() * 10000) + (releaseStage * 100) + list.at(4).toUInt();
72 break;
73 }
74 default:
75 qWarning() << "Unknown version format.";
76 break;
77 }
78 return result;
79}
80
81UBVersion::~UBVersion()
82{

Callers 4

operator <Method · 0.80
operator ==Method · 0.80
operator >Method · 0.80
downloadJsonFinishedMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected