mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
Added rpcs3 version object
Removed _PRGVER_ macros
This commit is contained in:
parent
079411eee8
commit
b52e885cde
8 changed files with 164 additions and 5 deletions
65
Utilities/version.cpp
Normal file
65
Utilities/version.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "stdafx.h"
|
||||
#include "version.h"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
std::string to_string(version_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case version_type::pre_alpha: return "Pre-Alpha";
|
||||
case version_type::alpha: return "Alpha";
|
||||
case version_type::beta: return "Beta";
|
||||
case version_type::release_candidate: return "RC";
|
||||
case version_type::release: return "Release";
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
version::version(std::uint8_t hi, std::uint8_t mid, std::uint8_t lo)
|
||||
: m_hi(hi)
|
||||
, m_mid(mid)
|
||||
, m_lo(lo)
|
||||
{
|
||||
}
|
||||
|
||||
version& version::type(version_type type, std::uint8_t type_index)
|
||||
{
|
||||
m_type = type;
|
||||
m_type_index = type_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::uint16_t version::to_hex() const
|
||||
{
|
||||
return (m_hi << 24) | (m_mid << 16) | (m_lo << 8) | ((std::uint8_t(m_type) & 0xf) << 4) | (m_type_index & 0xf);
|
||||
}
|
||||
|
||||
std::string version::to_string() const
|
||||
{
|
||||
std::string version = std::to_string(hi()) + "." + std::to_string(mid());
|
||||
|
||||
if (lo())
|
||||
{
|
||||
version += "." + std::to_string(lo());
|
||||
}
|
||||
|
||||
if (type() != version_type::release)
|
||||
{
|
||||
if (!postfix().empty())
|
||||
{
|
||||
version += "-" + postfix();
|
||||
}
|
||||
|
||||
version += " " + utils::to_string(type());
|
||||
|
||||
if (type_index() > 1)
|
||||
{
|
||||
version += " " + std::to_string(type_index());
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
71
Utilities/version.h
Normal file
71
Utilities/version.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
enum class version_type : std::uint8_t
|
||||
{
|
||||
pre_alpha,
|
||||
alpha,
|
||||
beta,
|
||||
release_candidate,
|
||||
release
|
||||
};
|
||||
|
||||
std::string to_string(version_type type);
|
||||
|
||||
class version
|
||||
{
|
||||
std::uint8_t m_hi;
|
||||
std::uint8_t m_mid;
|
||||
std::uint8_t m_lo;
|
||||
version_type m_type = version_type::release;
|
||||
std::uint8_t m_type_index = 1;
|
||||
std::string m_postfix;
|
||||
|
||||
public:
|
||||
version(std::uint8_t hi, std::uint8_t mid, std::uint8_t lo = 0);
|
||||
|
||||
version& type(version_type type, std::uint8_t type_index = 1);
|
||||
|
||||
std::uint8_t hi() const
|
||||
{
|
||||
return m_hi;
|
||||
}
|
||||
|
||||
std::uint8_t mid() const
|
||||
{
|
||||
return m_mid;
|
||||
}
|
||||
|
||||
std::uint8_t lo() const
|
||||
{
|
||||
return m_lo;
|
||||
}
|
||||
|
||||
version_type type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
std::string postfix() const
|
||||
{
|
||||
return m_postfix;
|
||||
}
|
||||
|
||||
version& postfix(const std::string& value)
|
||||
{
|
||||
m_postfix = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::uint8_t type_index() const
|
||||
{
|
||||
return m_type_index;
|
||||
}
|
||||
|
||||
std::uint16_t to_hex() const;
|
||||
std::string to_string() const;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue