1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/components/esm/formidrefid.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.3 KiB
C++
Raw Normal View History

#ifndef OPENMW_COMPONENTS_ESM_FORMIDREFID_HPP
#define OPENMW_COMPONENTS_ESM_FORMIDREFID_HPP
#include <functional>
#include <iosfwd>
2023-04-20 00:12:56 +00:00
#include <stdexcept>
2023-04-07 00:14:32 +00:00
#include <components/esm/formid.hpp>
namespace ESM
{
class FormIdRefId
{
public:
constexpr FormIdRefId() = default;
2023-04-20 00:12:56 +00:00
constexpr explicit FormIdRefId(ESM::FormId value)
: mValue(value)
{
2023-04-20 00:12:56 +00:00
if ((mValue.mIndex & 0xff000000) != 0)
throw std::invalid_argument("Invalid FormIdRefId index value: " + std::to_string(mValue.mIndex));
}
2023-04-07 00:14:32 +00:00
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:
2023-04-07 00:14:32 +00:00
ESM::FormId mValue;
};
}
namespace std
{
template <>
struct hash<ESM::FormIdRefId>
{
2023-04-07 00:14:32 +00:00
std::size_t operator()(ESM::FormIdRefId value) const noexcept { return std::hash<ESM::FormId>{}(value.mValue); }
};
}
#endif