Added update checker
This commit is contained in:
parent
08680c6e94
commit
eec6cdb8dd
7 changed files with 153 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "StringHelpers.hpp"
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
std::vector<std::string> split_string_by_token(std::string str, std::string token) {
|
||||
// slightly modified from: https://stackoverflow.com/a/46943631
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ std::vector<std::string> split_string_by_token(std::string str, std::string toke
|
|||
|
||||
// Hex character must be capitalized if it is a letter
|
||||
uint8_t ascii_hex_char_to_number_no_checks(char asciiHex);
|
||||
|
||||
std::string byte_vector_to_hex_str(const std::vector<uint8_t>& byteVec);
|
||||
|
||||
std::string read_file_to_string(const std::filesystem::path& filePath);
|
||||
void remove_whitespaces_from_str(std::string& str);
|
||||
|
|
|
|||
30
include/Helpers/VersionNumber.cpp
Normal file
30
include/Helpers/VersionNumber.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "VersionNumber.hpp"
|
||||
#include "StringHelpers.hpp"
|
||||
|
||||
std::string version_numbers_to_version_str(const VersionNumber& versionNum) {
|
||||
return std::to_string(versionNum.major) + "." + std::to_string(versionNum.minor) + "." + std::to_string(versionNum.patch);
|
||||
}
|
||||
|
||||
bool operator>(const VersionNumber& a, const VersionNumber& b) {
|
||||
return (a.major > b.major) || (a.major == b.major && (a.minor > b.minor || (a.minor == b.minor && a.patch > b.patch)));
|
||||
}
|
||||
|
||||
bool operator==(const VersionNumber& a, const VersionNumber& b) {
|
||||
return a.major == b.major && a.minor == b.minor && a.patch == b.patch;
|
||||
}
|
||||
|
||||
std::optional<VersionNumber> version_str_to_version_numbers(const std::string& versionStr) {
|
||||
try {
|
||||
std::vector<std::string> splitStrings = split_string_by_token(versionStr, ".");
|
||||
if(splitStrings.size() != 3)
|
||||
return std::nullopt;
|
||||
VersionNumber toRet;
|
||||
toRet.major = std::stoul(splitStrings[0]);
|
||||
toRet.minor = std::stoul(splitStrings[1]);
|
||||
toRet.patch = std::stoul(splitStrings[2]);
|
||||
return toRet;
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
14
include/Helpers/VersionNumber.hpp
Normal file
14
include/Helpers/VersionNumber.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
struct VersionNumber {
|
||||
unsigned major;
|
||||
unsigned minor;
|
||||
unsigned patch;
|
||||
};
|
||||
|
||||
std::optional<VersionNumber> version_str_to_version_numbers(const std::string& versionStr);
|
||||
std::string version_numbers_to_version_str(const VersionNumber& versionNum);
|
||||
bool operator>(const VersionNumber& a, const VersionNumber& b);
|
||||
bool operator==(const VersionNumber& a, const VersionNumber& b);
|
||||
Loading…
Add table
Add a link
Reference in a new issue