Added param for Serializer::WriteStr.

This commit is contained in:
Arron David Nelson 2024-02-17 00:48:14 -08:00
parent 8e88412deb
commit b1adf15f89

View File

@ -396,7 +396,7 @@ namespace ehs
} }
template<typename T, typename O = UInt_64> template<typename T, typename O = UInt_64>
void WriteStr(const T* str, N inSize = 0) void WriteStr(const T* str, const bool sizeKnown, N inSize = 0)
{ {
if (!inSize) if (!inSize)
while (str[inSize]) while (str[inSize])
@ -424,6 +424,7 @@ namespace ehs
{ {
Util::Copy(&data[offset], &str[0], bSize); Util::Copy(&data[offset], &str[0], bSize);
if (!sizeKnown)
*(T*)&data[offset + inSize] = 0; *(T*)&data[offset + inSize] = 0;
} }
else else
@ -432,6 +433,7 @@ namespace ehs
for (N b = 0; b < sizeof(T); ++b) for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0; *(T*)&data[offset + bSize] = 0;
} }
} }
@ -443,12 +445,14 @@ namespace ehs
for (N b = 0; b < sizeof(T); ++b) for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0; *(T*)&data[offset + bSize] = 0;
} }
else else
{ {
Util::Copy(&data[offset], &str[0], bSize); Util::Copy(&data[offset], &str[0], bSize);
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0; *(T*)&data[offset + bSize] = 0;
} }
} }