From d20664f90a84da691baeae5fb55bb28f409ed577 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 6 May 2023 12:24:01 -0400 Subject: Automatically check for updates --- src/version.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/version.h (limited to 'src/version.h') 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 @@ +#ifndef VERSION_H_C757E53C +#define VERSION_H_C757E53C + +#include +#include + +struct Version { + int major = 0; + int minor = 0; + int revision = 0; + + constexpr Version(int major_arg, int minor_arg, int rev_arg) + : major(major_arg), minor(minor_arg), revision(rev_arg) {} + + Version(const std::string& ver_str) { + const std::regex version_regex("v([0-9]*)\.([0-9]*)\.([0-9]*)"); + std::smatch version_match; + + if (std::regex_match(ver_str, version_match, version_regex)) { + major = std::atoi(version_match[1].str().c_str()); + minor = std::atoi(version_match[2].str().c_str()); + revision = std::atoi(version_match[3].str().c_str()); + } + } + + bool operator<(const Version& rhs) const { + return (major < rhs.major) || + (major == rhs.major && + (minor < rhs.minor || + (minor == rhs.minor && revision < rhs.revision))); + } +}; + +std::ostream& operator<<(std::ostream& out, const Version& ver) { + return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; +} + +constexpr const Version kTrackerVersion = Version(0, 1, 0); + +#endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1