geode/loader/include/Geode/utils/VersionInfo.hpp

52 lines
1.3 KiB
C++
Raw Normal View History

2022-07-30 12:24:03 -04:00
#pragma once
#include "../DefaultInclude.hpp"
2022-07-30 12:24:03 -04:00
#include <string_view>
#include "../external/json/json.hpp"
2022-07-30 12:24:03 -04:00
namespace geode {
/**
2022-12-08 15:04:02 -05:00
* Class representing version information
2022-07-30 12:24:03 -04:00
* @class VersionInfo
*/
class GEODE_DLL VersionInfo {
protected:
int m_major = 1;
int m_minor = 0;
int m_patch = 0;
2022-10-30 14:59:20 -04:00
2022-07-30 12:24:03 -04:00
public:
2022-12-08 15:04:02 -05:00
constexpr VersionInfo() = default;
2022-07-30 12:24:03 -04:00
constexpr VersionInfo(int major, int minor, int patch) {
m_major = major;
m_minor = minor;
m_patch = patch;
}
VersionInfo(std::string const& versionString);
2022-12-08 15:04:02 -05:00
constexpr int getMajor() const {
return m_major;
}
2022-07-30 12:24:03 -04:00
2022-12-08 15:04:02 -05:00
constexpr int getMinor() const {
return m_minor;
}
2022-07-30 12:24:03 -04:00
2022-12-08 15:04:02 -05:00
constexpr int getPatch() const {
return m_patch;
}
constexpr std::strong_ordering operator<=>(VersionInfo const& other) const {
return std::tie(m_major, m_minor, m_patch) <=>
std::tie(other.m_major, other.m_minor, other.m_patch);
}
2022-07-30 12:24:03 -04:00
static bool validate(std::string const& string);
std::string toString() const;
};
2022-11-22 17:35:08 -05:00
void GEODE_DLL to_json(nlohmann::json& json, VersionInfo const& info);
2022-12-08 15:04:02 -05:00
std::ostream& GEODE_DLL operator<<(std::ostream& stream, VersionInfo const& version);
2022-07-30 12:24:03 -04:00
}