Files
fennec/include/fennec/core/version.h

123 lines
3.1 KiB
C++

// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 - 2026 Medusa Slockbower
//
// 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/>.
// =====================================================================================================================
///
/// \file fennec/core/version.h
/// \brief
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 - 2026 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_CORE_VERSION_H
#define FENNEC_CORE_VERSION_H
#if FENNEC_COMPILER_GCC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#if FENNEC_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable:4201)
#endif
#include <fennec/lang/types.h>
#include <fennec/string/string.h>
namespace fennec
{
///
/// \brief simple version struct for drivers and systems
struct version {
// Public Member Variables =============================================================================================
public:
/// \name Member Variables
/// @{
union {
uint64_t num; //!< long version number
struct {
uint16_t major = { 1 }; //!< the major version
uint16_t minor = { 0 }; //!< the minor version
uint16_t patch = { 0 }; //!< the patch version
uint16_t meta = { 0 }; //!< the meta version, e.g. "rc.1"
};
};
/// @}
// Comparison Operators ================================================================================================
public:
/// \name Comparison Operators
/// @{
///
/// \brief Equality Operator
/// \param lhs The e
friend bool operator==(const version& lhs, const version& rhs) {
return lhs.num == rhs.num;
}
friend bool operator!=(const version& lhs, const version& rhs) {
return lhs.num != rhs.num;
}
///
/// \brief
/// \param lhs
/// \param rhs
/// \return
friend bool operator<(const version& lhs, const version& rhs) {
return lhs.num < rhs.num;
// This generates branching instructions, even in -O4
//return lhs.major < rhs.major or(
// (lhs.major == rhs.major and lhs.minor < rhs.minor) or (
// lhs.minor == rhs.minor and lhs.patch < rhs.patch
// )
//);
}
friend bool operator>(const version& lhs, const version& rhs) {
return lhs.num > rhs.num;
}
/// @}
};
#ifdef FENNEC_COMPILER_GCC
#pragma GCC diagnostic pop
#endif
#if FENNEC_COMPILER_MSVC
#pragma warning(pop)
#endif
}
#endif // FENNEC_CORE_VERSION_H