// MassBuilderSaveTool // Copyright (C) 2021-2023 Guillaume Jacquemin // // 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 . #pragma once #include #include #include #include #include using namespace Corrade; namespace mbst { struct Version { explicit Version() = default; explicit Version(Containers::StringView str); 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 } long major = 0; long minor = 0; long patch = 0; bool prerelease = false; long fullVersion = 0; inline bool operator==(const Version& other) const { return fullVersion == other.fullVersion && prerelease == other.prerelease; } inline bool operator>(const Version& other) const { if((fullVersion > other.fullVersion) || (fullVersion == other.fullVersion && !prerelease && other.prerelease)) { return true; } else { return false; } } 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 }; }