mirror of https://github.com/OpenMW/openmw.git
Change FormId::toString to be consistent with RefId. Remove FormIdRefId.
parent
102826ddb6
commit
32f3a16db3
@ -1,38 +0,0 @@
|
||||
#include "formidrefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "serializerefid.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::uint64_t truncate(FormId value)
|
||||
{
|
||||
return (static_cast<std::uint64_t>(value.mContentFile) << 24) | value.mIndex;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FormIdRefId::toString() const
|
||||
{
|
||||
std::string result;
|
||||
const std::uint64_t v = truncate(mValue);
|
||||
result.resize(getHexIntegralSizeWith0x(v), '\0');
|
||||
serializeHexIntegral(v, 0, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string FormIdRefId::toDebugString() const
|
||||
{
|
||||
std::string result;
|
||||
const std::uint64_t v = truncate(mValue);
|
||||
serializeRefIdValue(v, formIdRefIdPrefix, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, FormIdRefId value)
|
||||
{
|
||||
return stream << value.toDebugString();
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_FORMIDREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_FORMIDREFID_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/esm/formid.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class FormIdRefId
|
||||
{
|
||||
public:
|
||||
constexpr FormIdRefId() = default;
|
||||
|
||||
constexpr explicit FormIdRefId(ESM::FormId value)
|
||||
: mValue(value)
|
||||
{
|
||||
if ((mValue.mIndex & 0xff000000) != 0)
|
||||
throw std::invalid_argument("Invalid FormIdRefId index value: " + std::to_string(mValue.mIndex));
|
||||
}
|
||||
|
||||
ESM::FormId getValue() const { return mValue; }
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
constexpr bool operator==(FormIdRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
||||
|
||||
constexpr bool operator<(FormIdRefId rhs) const noexcept { return mValue < rhs.mValue; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, FormIdRefId value);
|
||||
|
||||
friend struct std::hash<FormIdRefId>;
|
||||
|
||||
private:
|
||||
ESM::FormId mValue;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::FormIdRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::FormIdRefId value) const noexcept { return std::hash<ESM::FormId>{}(value.mValue); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue