This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.h
74 lines (63 loc) · 2.34 KB
/
version.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef VERSION_H
#define VERSION_H
#include "versiontype.h"
#include <string>
#include <cstdint>
namespace VRCE {
struct Version
{
static Version Parse(const std::string& versionString);
Version();
Version(std::uint16_t major);
Version(std::uint16_t major, std::uint8_t minor);
Version(std::uint16_t major, std::uint8_t minor, std::uint8_t build);
Version(std::uint16_t major, std::uint8_t minor, std::uint8_t build, VersionType type);
Version(std::uint16_t major, std::uint8_t minor, std::uint8_t build, VersionType type, std::uint8_t typeNumber);
Version(const VRCE::Version& other);
std::uint16_t major() const noexcept;
std::uint8_t minor() const noexcept;
std::uint8_t build() const noexcept;
VersionType type() const noexcept;
std::uint8_t typeNumber() const noexcept;
void setMajor(std::uint16_t major) noexcept
{
m_data &= ~((0xFFFFull) << 48);
m_data |= ((std::uint64_t)major << 48);
}
void setMinor(std::uint8_t minor) noexcept
{
m_data &= ~((0xFFull) << 40);
m_data |= ((std::uint64_t)minor << 40);
}
void setBuild(std::uint8_t patch) noexcept
{
m_data &= ~((0xFFull) << 32);
m_data |= ((std::uint64_t)patch << 32);
}
void setType(VersionType type) noexcept
{
m_data &= ~((0xFFull) << 24);
m_data |= ((std::uint64_t)type << 24);
}
void setTypeNumber(std::uint8_t typeNumber) noexcept
{
m_data &= ~((0xFFull) << 16);
m_data |= ((std::uint64_t)typeNumber << 16);
}
std::string toString() const;
bool operator==(const Version& other) const noexcept { return m_data == other.m_data; }
bool operator!=(const Version& other) const noexcept { return m_data != other.m_data; }
bool operator< (const Version& other) const noexcept { return m_data < other.m_data; }
bool operator> (const Version& other) const noexcept { return m_data > other.m_data; }
bool operator<=(const Version& other) const noexcept { return m_data <= other.m_data; }
bool operator>=(const Version& other) const noexcept { return m_data >= other.m_data; }
VRCE::Version& operator=(const VRCE::Version& other);
private:
std::uint64_t m_data;
};
/*
const Version VersionMin { 0x0000000000000000ull };
const Version VersionMax { 0xFFFFFFFFFFFFFFFFull };
*/
}
#endif // VERSION_H