Files

76 lines
1.1 KiB
C++
Raw Permalink Normal View History

2016-05-07 21:38:52 +03:00
#pragma once
2016-07-21 01:00:31 +03:00
2020-12-12 15:01:29 +03:00
#include "util/types.hpp"
2016-05-07 21:38:52 +03:00
#include <string>
namespace utils
{
2016-07-21 01:00:31 +03:00
enum class version_type : uint
2016-05-07 21:38:52 +03:00
{
pre_alpha,
alpha,
beta,
release_candidate,
release
};
std::string to_string(version_type type);
class version
{
2016-07-21 01:00:31 +03:00
uint m_hi;
uint m_mid;
uint m_lo;
2016-05-07 21:38:52 +03:00
version_type m_type = version_type::release;
2016-07-21 01:00:31 +03:00
uint m_type_index = 1;
2026-06-18 15:54:22 +02:00
std::string_view m_postfix;
2016-05-07 21:38:52 +03:00
public:
2026-06-18 15:54:22 +02:00
constexpr version(uint hi, uint mid, uint lo, version_type type, uint type_index, std::string_view postfix)
2016-07-21 01:00:31 +03:00
: m_hi(hi)
, m_mid(mid)
, m_lo(lo)
, m_type(type)
, m_type_index(type_index)
, m_postfix(postfix)
{
}
2016-05-07 21:38:52 +03:00
2016-07-21 01:00:31 +03:00
uint hi() const
2016-05-07 21:38:52 +03:00
{
return m_hi;
}
2016-07-21 01:00:31 +03:00
uint mid() const
2016-05-07 21:38:52 +03:00
{
return m_mid;
}
2016-07-21 01:00:31 +03:00
uint lo() const
2016-05-07 21:38:52 +03:00
{
return m_lo;
}
version_type type() const
{
return m_type;
}
2026-06-18 15:54:22 +02:00
std::string_view postfix() const
2016-05-07 21:38:52 +03:00
{
return m_postfix;
}
2016-07-21 01:00:31 +03:00
uint type_index() const
2016-05-07 21:38:52 +03:00
{
return m_type_index;
}
2016-07-21 01:00:31 +03:00
uint to_hex() const;
2026-06-18 15:54:22 +02:00
std::string to_string(bool simple = false) const;
2016-05-07 21:38:52 +03: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 21:38:52 +03:00
}