2023-02-10 23:08:59 +00:00
|
|
|
#include "indexrefid.hpp"
|
|
|
|
|
2023-03-24 11:31:37 +00:00
|
|
|
#include "serializerefid.hpp"
|
2023-02-10 23:08:59 +00:00
|
|
|
|
2023-03-24 11:31:37 +00:00
|
|
|
#include <ostream>
|
2023-02-10 23:08:59 +00:00
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
std::string IndexRefId::toString() const
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
std::string result;
|
2023-04-07 19:40:44 +00:00
|
|
|
result.resize(sizeof(mRecordType) + getHexIntegralSize(mValue) + 3, '\0');
|
2023-03-24 11:31:37 +00:00
|
|
|
std::memcpy(result.data(), &mRecordType, sizeof(mRecordType));
|
|
|
|
result[sizeof(mRecordType)] = ':';
|
2023-04-07 19:40:44 +00:00
|
|
|
serializeHexIntegral(mValue, sizeof(mRecordType) + 1, result);
|
2023-03-24 11:31:37 +00:00
|
|
|
return result;
|
2023-02-10 23:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string IndexRefId::toDebugString() const
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
std::string result;
|
2023-04-07 19:40:44 +00:00
|
|
|
serializeRefIdPrefix(sizeof(mRecordType) + getHexIntegralSize(mValue) + 1, indexRefIdPrefix, result);
|
2023-03-24 11:31:37 +00:00
|
|
|
std::memcpy(result.data() + indexRefIdPrefix.size(), &mRecordType, sizeof(mRecordType));
|
|
|
|
result[indexRefIdPrefix.size() + sizeof(mRecordType)] = ':';
|
2023-04-07 19:40:44 +00:00
|
|
|
serializeHexIntegral(mValue, indexRefIdPrefix.size() + sizeof(mRecordType) + 1, result);
|
2023-03-24 11:31:37 +00:00
|
|
|
return result;
|
2023-02-10 23:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& stream, IndexRefId value)
|
|
|
|
{
|
2023-03-24 11:31:37 +00:00
|
|
|
return stream << value.toDebugString();
|
2023-02-10 23:08:59 +00:00
|
|
|
}
|
|
|
|
}
|