mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +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
25
AK/Endian.h
25
AK/Endian.h
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Platform.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -70,10 +71,22 @@ ALWAYS_INLINE T convert_between_host_and_network_endian(T value)
|
|||
return convert_between_host_and_big_endian(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class LittleEndian;
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream&, LittleEndian<T>&);
|
||||
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream&, LittleEndian<T>);
|
||||
|
||||
template<typename T>
|
||||
class [[gnu::packed]] LittleEndian
|
||||
{
|
||||
public:
|
||||
friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&);
|
||||
friend OutputStream& operator<<<T>(OutputStream&, LittleEndian<T>);
|
||||
|
||||
LittleEndian() { }
|
||||
|
||||
LittleEndian(T value)
|
||||
|
@ -87,10 +100,22 @@ private:
|
|||
T m_value { 0 };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class BigEndian;
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(InputStream&, BigEndian<T>&);
|
||||
|
||||
template<typename T>
|
||||
OutputStream& operator<<(OutputStream&, BigEndian<T>);
|
||||
|
||||
template<typename T>
|
||||
class [[gnu::packed]] BigEndian
|
||||
{
|
||||
public:
|
||||
friend InputStream& operator>><T>(InputStream&, BigEndian<T>&);
|
||||
friend OutputStream& operator<<<T>(OutputStream&, BigEndian<T>);
|
||||
|
||||
BigEndian() { }
|
||||
|
||||
BigEndian(T value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue