mirror of https://github.com/OpenMW/openmw.git
Support generated RefId as std::uint64_t
parent
0992624c8b
commit
86293af084
@ -0,0 +1,24 @@
|
||||
#include "generatedrefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
std::string GeneratedRefId::toString() const
|
||||
{
|
||||
return std::to_string(mValue);
|
||||
}
|
||||
|
||||
std::string GeneratedRefId::toDebugString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, GeneratedRefId value)
|
||||
{
|
||||
return stream << "Generated{" << value.mValue << '}';
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_GENERATEDREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_GENERATEDREFID_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class GeneratedRefId
|
||||
{
|
||||
public:
|
||||
constexpr explicit GeneratedRefId(std::uint64_t value) noexcept
|
||||
: mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr std::uint64_t getValue() const { return mValue; }
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
constexpr bool operator==(GeneratedRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
||||
|
||||
constexpr bool operator<(GeneratedRefId rhs) const noexcept { return mValue < rhs.mValue; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, GeneratedRefId value);
|
||||
|
||||
friend struct std::hash<GeneratedRefId>;
|
||||
|
||||
private:
|
||||
std::uint64_t mValue;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::GeneratedRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::GeneratedRefId value) const noexcept
|
||||
{
|
||||
return std::hash<std::uint64_t>{}(value.mValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue