mirror of https://github.com/SeanOMik/libki.git
dml: Fix a problem that would have only been apparent on big-endian PCs
This commit is contained in:
parent
6883cae2ae
commit
a1689a142c
|
@ -14,7 +14,7 @@ namespace dml
|
|||
ValueBytes<DBL> data;
|
||||
data.value = m_value;
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[7]);
|
||||
std::reverse(&data.buff[0], &data.buff[8]);
|
||||
ostream.write(data.buff, sizeof(DBL));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace dml
|
|||
ValueBytes<DBL> data;
|
||||
istream.read(data.buff, sizeof(DBL));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[8]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace dml
|
|||
ValueBytes<FLT> data;
|
||||
data.value = m_value;
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
ostream.write(data.buff, sizeof(FLT));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace dml
|
|||
ValueBytes<FLT> data;
|
||||
istream.read(data.buff, sizeof(FLT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<GID> data;
|
||||
data.value = m_value;
|
||||
if (data.buff[0] == ((m_value & 0xFF00000000000000) >> 56))
|
||||
std::reverse(&data.buff[0], &data.buff[7]);
|
||||
std::reverse(&data.buff[0], &data.buff[8]);
|
||||
ostream.write(data.buff, sizeof(GID));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dml
|
|||
ValueBytes<GID> data;
|
||||
istream.read(data.buff, sizeof(GID));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[7]);
|
||||
std::reverse(&data.buff[0], &data.buff[8]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<INT> data;
|
||||
data.value = m_value;
|
||||
if (data.buff[0] == ((m_value & 0xFF000000) >> 24))
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
ostream.write(data.buff, sizeof(INT));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dml
|
|||
ValueBytes<INT> data;
|
||||
istream.read(data.buff, sizeof(INT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<SHRT> data;
|
||||
data.value = m_value;
|
||||
if (data.buff[0] == ((m_value & 0xFF00) >> 8))
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
ostream.write(data.buff, sizeof(SHRT));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dml
|
|||
ValueBytes<SHRT> data;
|
||||
istream.read(data.buff, sizeof(SHRT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<USHRT> data;
|
||||
data.value = m_value.length();
|
||||
if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8))
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
ostream.write(data.buff, sizeof(USHRT));
|
||||
ostream.write(m_value.c_str(), m_value.length());
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace dml
|
|||
ValueBytes<USHRT> length_data;
|
||||
istream.read(length_data.buff, sizeof(USHRT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&length_data.buff[0], &length_data.buff[1]);
|
||||
std::reverse(&length_data.buff[0], &length_data.buff[2]);
|
||||
|
||||
// Read the data into a buffer
|
||||
char *data = new char[length_data.value + 1] { 0 };
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<UINT> data;
|
||||
data.value = m_value;
|
||||
if (data.buff[0] == ((m_value & 0xFF000000) >> 24))
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
ostream.write(data.buff, sizeof(UINT));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dml
|
|||
ValueBytes<UINT> data;
|
||||
istream.read(data.buff, sizeof(UINT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[3]);
|
||||
std::reverse(&data.buff[0], &data.buff[4]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<USHRT> data;
|
||||
data.value = m_value;
|
||||
if (data.buff[0] == ((m_value & 0xFF00) >> 8))
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
ostream.write(data.buff, sizeof(USHRT));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dml
|
|||
ValueBytes<USHRT> data;
|
||||
istream.read(data.buff, sizeof(USHRT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
m_value = data.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace dml
|
|||
ValueBytes<USHRT> data;
|
||||
data.value = m_value.length();
|
||||
if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8))
|
||||
std::reverse(&data.buff[0], &data.buff[1]);
|
||||
std::reverse(&data.buff[0], &data.buff[2]);
|
||||
ostream.write(data.buff, sizeof(USHRT));
|
||||
ostream.write((char *)m_value.c_str(), m_value.length() * sizeof(char16_t));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace dml
|
|||
ValueBytes<USHRT> length_data;
|
||||
istream.read(length_data.buff, sizeof(USHRT));
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&length_data.buff[0], &length_data.buff[1]);
|
||||
std::reverse(&length_data.buff[0], &length_data.buff[2]);
|
||||
|
||||
// Read the data into a buffer
|
||||
size_t length = length_data.value * sizeof(char16_t);
|
||||
|
@ -35,7 +35,7 @@ namespace dml
|
|||
for (int i = 0; i < length; i += 2)
|
||||
{
|
||||
if (endianness_check.buff[0] == 0x01)
|
||||
std::reverse(&data[i], &data[i + 1]);
|
||||
std::reverse(&data[i], &data[i + 2]);
|
||||
}
|
||||
m_value = WSTR((char16_t *)data);
|
||||
delete[] data;
|
||||
|
|
Loading…
Reference in New Issue