2016-05-07 18:38:52 +00:00
|
|
|
#pragma once
|
2016-07-20 22:00:31 +00:00
|
|
|
|
2020-12-12 12:01:29 +00:00
|
|
|
#include "util/types.hpp"
|
2016-05-07 18:38:52 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace utils
|
|
|
|
{
|
2016-07-20 22:00:31 +00:00
|
|
|
enum class version_type : uint
|
2016-05-07 18:38:52 +00:00
|
|
|
{
|
|
|
|
pre_alpha,
|
|
|
|
alpha,
|
|
|
|
beta,
|
|
|
|
release_candidate,
|
|
|
|
release
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string to_string(version_type type);
|
|
|
|
|
|
|
|
class version
|
|
|
|
{
|
2016-07-20 22:00:31 +00:00
|
|
|
uint m_hi;
|
|
|
|
uint m_mid;
|
|
|
|
uint m_lo;
|
2016-05-07 18:38:52 +00:00
|
|
|
version_type m_type = version_type::release;
|
2016-07-20 22:00:31 +00:00
|
|
|
uint m_type_index = 1;
|
|
|
|
const char* m_postfix;
|
2016-05-07 18:38:52 +00:00
|
|
|
|
|
|
|
public:
|
2016-07-20 22:00:31 +00:00
|
|
|
constexpr version(uint hi, uint mid, uint lo, version_type type, uint type_index, const char* postfix)
|
|
|
|
: m_hi(hi)
|
|
|
|
, m_mid(mid)
|
|
|
|
, m_lo(lo)
|
|
|
|
, m_type(type)
|
|
|
|
, m_type_index(type_index)
|
|
|
|
, m_postfix(postfix)
|
|
|
|
{
|
|
|
|
}
|
2016-05-07 18:38:52 +00:00
|
|
|
|
2016-07-20 22:00:31 +00:00
|
|
|
uint hi() const
|
2016-05-07 18:38:52 +00:00
|
|
|
{
|
|
|
|
return m_hi;
|
|
|
|
}
|
|
|
|
|
2016-07-20 22:00:31 +00:00
|
|
|
uint mid() const
|
2016-05-07 18:38:52 +00:00
|
|
|
{
|
|
|
|
return m_mid;
|
|
|
|
}
|
|
|
|
|
2016-07-20 22:00:31 +00:00
|
|
|
uint lo() const
|
2016-05-07 18:38:52 +00:00
|
|
|
{
|
|
|
|
return m_lo;
|
|
|
|
}
|
|
|
|
|
|
|
|
version_type type() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string postfix() const
|
|
|
|
{
|
|
|
|
return m_postfix;
|
|
|
|
}
|
|
|
|
|
2016-07-20 22:00:31 +00:00
|
|
|
uint type_index() const
|
2016-05-07 18:38:52 +00:00
|
|
|
{
|
|
|
|
return m_type_index;
|
|
|
|
}
|
|
|
|
|
2016-07-20 22:00:31 +00:00
|
|
|
uint to_hex() const;
|
2016-05-07 18:38:52 +00:00
|
|
|
std::string to_string() const;
|
|
|
|
};
|
2020-06-19 13:38:51 +00:00
|
|
|
|
|
|
|
// Generic version comparison (e.g. 0.0.5 vs 1.3)
|
|
|
|
int compare_versions(const std::string& v1, const std::string& v2, bool& ok);
|
2016-05-07 18:38:52 +00:00
|
|
|
}
|