mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
AK: Don't swap endianness when writing endian wrappers to stream.
This commit is contained in:
parent
054638c355
commit
e68b158a52
3 changed files with 55 additions and 26 deletions
43
AK/Stream.h
43
AK/Stream.h
|
@ -76,33 +76,36 @@ class DuplexStream
|
|||
, public OutputStream {
|
||||
};
|
||||
|
||||
inline InputStream& operator>>(InputStream& stream, Bytes bytes)
|
||||
{
|
||||
stream.read_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
inline OutputStream& operator<<(OutputStream& stream, ReadonlyBytes bytes)
|
||||
{
|
||||
stream.write_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream& stream, LittleEndian<T>& value)
|
||||
{
|
||||
T temporary;
|
||||
stream >> temporary;
|
||||
value = temporary;
|
||||
return stream;
|
||||
return stream >> Bytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
template<typename T>
|
||||
InputStream& operator<<(InputStream& stream, LittleEndian<T> value)
|
||||
OutputStream& operator<<(OutputStream& stream, LittleEndian<T> value)
|
||||
{
|
||||
stream << static_cast<T>(value);
|
||||
return stream;
|
||||
return stream << ReadonlyBytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream& stream, BigEndian<T>& value)
|
||||
{
|
||||
T temporary;
|
||||
stream >> temporary;
|
||||
value = temporary;
|
||||
return stream;
|
||||
return stream >> Bytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
template<typename T>
|
||||
InputStream& operator<<(InputStream& stream, BigEndian<T> value)
|
||||
OutputStream& operator<<(OutputStream& stream, BigEndian<T> value)
|
||||
{
|
||||
stream << static_cast<T>(value);
|
||||
return stream;
|
||||
return stream << ReadonlyBytes { &value.m_value, sizeof(value.m_value) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -177,18 +180,6 @@ inline OutputStream& operator<<(OutputStream& stream, bool value)
|
|||
return stream;
|
||||
}
|
||||
|
||||
inline InputStream& operator>>(InputStream& stream, Bytes bytes)
|
||||
{
|
||||
stream.read_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline OutputStream& operator<<(OutputStream& stream, ReadonlyBytes bytes)
|
||||
{
|
||||
stream.write_or_error(bytes);
|
||||
return stream;
|
||||
}
|
||||
|
||||
class InputMemoryStream final : public InputStream {
|
||||
friend InputMemoryStream& operator>>(InputMemoryStream& stream, String& string);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue