2021-10-19 23:00:54 +01:00
|
|
|
#include "VersionNumber.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
namespace Bloom
|
|
|
|
|
{
|
|
|
|
|
VersionNumber::VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch)
|
2022-06-01 21:48:27 +01:00
|
|
|
: major{major}
|
|
|
|
|
, minor{minor}
|
|
|
|
|
, patch{patch}
|
|
|
|
|
{
|
2022-02-05 15:32:08 +00:00
|
|
|
this->combined = static_cast<std::uint32_t>(
|
|
|
|
|
std::stoul(std::to_string(this->major) + std::to_string(this->minor) + std::to_string(this->patch))
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-10-19 23:00:54 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
VersionNumber::VersionNumber(const std::string& versionNumber) {
|
|
|
|
|
auto versionNumberQStr = QString::fromStdString(versionNumber);
|
|
|
|
|
const auto explodedString = versionNumberQStr.split('.');
|
2021-10-19 23:00:54 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
this->major = explodedString.value(0, "0").toUShort();
|
|
|
|
|
this->minor = explodedString.value(1, "0").toUShort();
|
|
|
|
|
this->patch = explodedString.value(2, "0").toUShort();
|
2021-10-19 23:00:54 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
this->combined = versionNumberQStr.remove('.').toUInt();
|
|
|
|
|
}
|
2021-10-19 23:00:54 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
std::string VersionNumber::toString() const {
|
|
|
|
|
return std::to_string(this->major) + "." + std::to_string(this->minor) + "." + std::to_string(this->patch);
|
|
|
|
|
}
|
2021-10-19 23:00:54 +01:00
|
|
|
}
|