mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
#include "indexrefid.hpp"
|
|
|
|
#include "serializerefid.hpp"
|
|
|
|
#include <ostream>
|
|
|
|
namespace ESM
|
|
{
|
|
std::string IndexRefId::toString() const
|
|
{
|
|
std::string result;
|
|
constexpr std::size_t separator = 1;
|
|
result.resize(sizeof(mRecordType) + separator + getHexIntegralSizeWith0x(mValue), '\0');
|
|
std::memcpy(result.data(), &mRecordType, sizeof(mRecordType));
|
|
result[sizeof(mRecordType)] = ':';
|
|
serializeHexIntegral(mValue, sizeof(mRecordType) + separator, result);
|
|
return result;
|
|
}
|
|
|
|
std::string IndexRefId::toDebugString() const
|
|
{
|
|
std::string result;
|
|
constexpr std::size_t separator = 1;
|
|
serializeRefIdPrefix(
|
|
sizeof(mRecordType) + separator + getHexIntegralSizeWith0x(mValue), indexRefIdPrefix, result);
|
|
std::memcpy(result.data() + indexRefIdPrefix.size(), &mRecordType, sizeof(mRecordType));
|
|
result[indexRefIdPrefix.size() + sizeof(mRecordType)] = ':';
|
|
serializeHexIntegral(mValue, indexRefIdPrefix.size() + sizeof(mRecordType) + separator, result);
|
|
return result;
|
|
}
|
|
|
|
std::ostream& operator<<(std::ostream& stream, IndexRefId value)
|
|
{
|
|
return stream << value.toDebugString();
|
|
}
|
|
}
|