-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.hpp
More file actions
57 lines (44 loc) · 1.79 KB
/
version.hpp
File metadata and controls
57 lines (44 loc) · 1.79 KB
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
#ifndef VERSION_HPP_
#define VERSION_HPP_
#include <glibmm/ustring.h>
#include <istream>
#include <ostream>
#include "attributes.hpp"
/* xxx remember to change CURRENT_VERSION below when updating xxx */
struct Version {
unsigned short major;
unsigned short minor;
unsigned short patch;
INLINE Version() {}
INLINE Version(unsigned short maj, unsigned short min = 0, unsigned short pch = 0) {
major = maj;
minor = min;
patch = pch;
}
INLINE ~Version() {}
INLINE operator Glib::ustring() const {
return Glib::ustring::compose("%1.%2.%3", major, minor, patch);
}
INLINE bool operator<(const Version &other) const {
return (major < other.major || (major == other.major && (minor < other.minor || (minor == other.minor && patch < other.patch))));
}
INLINE bool operator>(const Version &other) const {
return (major > other.major || (major == other.major && (minor > other.minor || (minor == other.minor && patch > other.patch))));
}
INLINE bool operator==(const Version &other) const {
return (major == other.major && minor == other.minor && patch == other.patch);
}
INLINE bool operator!=(const Version &other) const {
return (major != other.major || minor != other.minor || patch != other.patch);
}
INLINE bool operator<=(const Version &other) const {
return (major < other.major || (major == other.major && (minor < other.minor || (minor == other.minor && patch <= other.patch))));
}
INLINE bool operator>=(const Version &other) const {
return (major > other.major || (major == other.major && (minor > other.minor || (minor == other.minor && patch >= other.patch))));
}
};
static const Version CURRENT_VERSION = Version{1,3,1};
std::ostream &operator<<(std::ostream &out, const Version &ver);
std::istream &operator>>(std::istream &in, Version &ver);
#endif /* VERSION_HPP_ */