2023-10-29 11:32:17 +01:00
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2023-10-29 11:32:17 +01:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#include <Corrade/Containers/Array.h>
|
|
|
|
#include <Corrade/Containers/String.h>
|
|
|
|
#include <Corrade/Containers/StringView.h>
|
|
|
|
#include <Corrade/Utility/Format.h>
|
|
|
|
|
|
|
|
using namespace Corrade;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
namespace mbst {
|
|
|
|
|
2023-10-29 11:32:17 +01:00
|
|
|
struct Version {
|
|
|
|
explicit Version() = default;
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
explicit Version(Containers::StringView str);
|
2023-10-29 11:32:17 +01:00
|
|
|
|
|
|
|
constexpr explicit Version(long major_, long minor_, long patch_, bool prerelease_):
|
|
|
|
major{major_}, minor{minor_}, patch{patch_}, prerelease{prerelease_},
|
|
|
|
fullVersion{major_ * 10000 + minor_ * 100 + patch_}
|
|
|
|
{
|
|
|
|
//ctor
|
|
|
|
}
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
long major = 0;
|
|
|
|
long minor = 0;
|
|
|
|
long patch = 0;
|
|
|
|
bool prerelease = false;
|
2023-10-29 11:32:17 +01:00
|
|
|
long fullVersion = 0;
|
|
|
|
|
2024-08-23 17:09:14 +02:00
|
|
|
bool operator==(const Version& other) const {
|
2023-10-29 11:32:17 +01:00
|
|
|
return fullVersion == other.fullVersion && prerelease == other.prerelease;
|
|
|
|
}
|
|
|
|
|
2024-08-23 17:09:14 +02:00
|
|
|
bool operator>(const Version& other) const {
|
2023-10-29 11:32:17 +01:00
|
|
|
if((fullVersion > other.fullVersion) ||
|
|
|
|
(fullVersion == other.fullVersion && !prerelease && other.prerelease))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2024-08-23 17:09:14 +02:00
|
|
|
|
|
|
|
return false;
|
2023-10-29 11:32:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit operator Containers::String() const {
|
|
|
|
return Utility::format("{}.{}.{}{}", major, minor, patch, prerelease ? "-pre" : "");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr Version current_version{
|
|
|
|
SAVETOOL_VERSION_MAJOR,
|
|
|
|
SAVETOOL_VERSION_MINOR,
|
|
|
|
SAVETOOL_VERSION_PATCH,
|
|
|
|
SAVETOOL_VERSION_PRERELEASE
|
|
|
|
};
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}
|