2023-02-20 22:11:18 +00:00
|
|
|
#include "formidrefid.hpp"
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
2023-04-07 00:14:32 +00:00
|
|
|
#include "serializerefid.hpp"
|
|
|
|
|
2023-02-20 22:11:18 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 22:11:18 +00:00
|
|
|
std::string FormIdRefId::toString() const
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
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);
|
2023-03-24 11:31:37 +00:00
|
|
|
return result;
|
2023-02-20 22:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string FormIdRefId::toDebugString() const
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
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);
|
2023-03-24 11:31:37 +00:00
|
|
|
return result;
|
2023-02-20 22:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& stream, FormIdRefId value)
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
return stream << value.toDebugString();
|
2023-02-20 22:11:18 +00:00
|
|
|
}
|
|
|
|
}
|