1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-28 18:18:52 +00:00
OpenMW/components/esm/formidrefid.cpp

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

39 lines
895 B
C++
Raw Normal View History

#include "formidrefid.hpp"
#include <ostream>
2023-04-07 00:14:32 +00:00
#include "serializerefid.hpp"
namespace ESM
{
2023-04-20 00:12:56 +00:00
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;
2023-04-20 00:12:56 +00:00
const std::uint64_t v = truncate(mValue);
result.resize(getHexIntegralSizeWith0x(v), '\0');
2023-04-07 00:14:32 +00:00
serializeHexIntegral(v, 0, result);
return result;
}
std::string FormIdRefId::toDebugString() const
{
std::string result;
2023-04-20 00:12:56 +00:00
const std::uint64_t v = truncate(mValue);
2023-04-07 00:14:32 +00:00
serializeRefIdValue(v, formIdRefIdPrefix, result);
return result;
}
std::ostream& operator<<(std::ostream& stream, FormIdRefId value)
{
return stream << value.toDebugString();
}
}