From 35bcdefdf78215cfd8d36a26e182cc323dd177ac Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Tue, 29 Nov 2022 15:40:24 +0100 Subject: [PATCH] AK: Add Byte accessors for BigEndian and LittleEndian --- AK/Endian.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AK/Endian.h b/AK/Endian.h index 4bf778a351..5ce022eff7 100644 --- a/AK/Endian.h +++ b/AK/Endian.h @@ -100,6 +100,10 @@ public: constexpr operator T() const { return convert_between_host_and_little_endian(m_value); } + // This returns the internal representation. In this case, that is the value stored in little endian format. + constexpr Bytes bytes() { return Bytes { &m_value, sizeof(m_value) }; } + constexpr ReadonlyBytes bytes() const { return ReadonlyBytes { &m_value, sizeof(m_value) }; } + private: T m_value { 0 }; }; @@ -128,6 +132,10 @@ public: constexpr operator T() const { return convert_between_host_and_big_endian(m_value); } + // This returns the internal representation. In this case, that is the value stored in big endian format. + constexpr Bytes bytes() { return Bytes { &m_value, sizeof(m_value) }; } + constexpr ReadonlyBytes bytes() const { return ReadonlyBytes { &m_value, sizeof(m_value) }; } + private: T m_value { 0 }; };