about summary refs log tree commit diff stats
path: root/src/version.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-05-06 12:24:01 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-05-06 12:24:01 -0400
commitd20664f90a84da691baeae5fb55bb28f409ed577 (patch)
tree6a259fb645cda39aa479849e6881e78f91924fad /src/version.h
parentd7212d755dca7f4fd99cf4b775cd0d372d7bcbb2 (diff)
downloadlingo-ap-tracker-d20664f90a84da691baeae5fb55bb28f409ed577.tar.gz
lingo-ap-tracker-d20664f90a84da691baeae5fb55bb28f409ed577.tar.bz2
lingo-ap-tracker-d20664f90a84da691baeae5fb55bb28f409ed577.zip
Automatically check for updates
Diffstat (limited to 'src/version.h')
-rw-r--r--src/version.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..c45ff53 --- /dev/null +++ b/src/version.h
@@ -0,0 +1,40 @@
1#ifndef VERSION_H_C757E53C
2#define VERSION_H_C757E53C
3
4#include <iostream>
5#include <regex>
6
7struct Version {
8 int major = 0;
9 int minor = 0;
10 int revision = 0;
11
12 constexpr Version(int major_arg, int minor_arg, int rev_arg)
13 : major(major_arg), minor(minor_arg), revision(rev_arg) {}
14
15 Version(const std::string& ver_str) {
16 const std::regex version_regex("v([0-9]*)\.([0-9]*)\.([0-9]*)");
17 std::smatch version_match;
18
19 if (std::regex_match(ver_str, version_match, version_regex)) {
20 major = std::atoi(version_match[1].str().c_str());
21 minor = std::atoi(version_match[2].str().c_str());
22 revision = std::atoi(version_match[3].str().c_str());
23 }
24 }
25
26 bool operator<(const Version& rhs) const {
27 return (major < rhs.major) ||
28 (major == rhs.major &&
29 (minor < rhs.minor ||
30 (minor == rhs.minor && revision < rhs.revision)));
31 }
32};
33
34std::ostream& operator<<(std::ostream& out, const Version& ver) {
35 return out << "v" << ver.major << "." << ver.minor << "." << ver.revision;
36}
37
38constexpr const Version kTrackerVersion = Version(0, 1, 0);
39
40#endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file