1
0
Fork 0

consider native byte order when interpreting data

This commit is contained in:
Kevin Matz 2023-05-18 14:38:32 -04:00
parent 14e4bdc5b5
commit 13981ff727
1 changed files with 5 additions and 13 deletions

View File

@ -125,16 +125,12 @@ public:
else
{
auto bytes = reinterpret_cast<uint8_t*>(&ret);
switch (order_) {
case LittleEndian:
if (order_ == endian::native)
for (int_fast8_t i = 0; i < width; i++)
bytes[i] = get();
break;
case BigEndian:
for (int_fast8_t i = width; --i >= 0;)
else
for (int_fast8_t i = width; --i >= 0;)
bytes[i] = get();
break;
}
}
if (!in_avail())
setstate(std::ios_base::eofbit);
@ -153,16 +149,12 @@ public:
return;
}
auto bytes = reinterpret_cast<const uint8_t*>(&val);
switch (order_) {
case LittleEndian:
if (order_ == endian::native)
for (int_fast8_t i = 0; i < width; i++)
put(bytes[i]);
break;
case BigEndian:
else
for (int_fast8_t i = width; --i >= 0;)
put(bytes[i]);
break;
}
}
private: