mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add Byte accessors for BigEndian and LittleEndian
This commit is contained in:
parent
56422e37e0
commit
35bcdefdf7
Notes:
sideshowbarker
2024-07-17 05:06:13 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/35bcdefdf7 Pull-request: https://github.com/SerenityOS/serenity/pull/16264
1 changed files with 8 additions and 0 deletions
|
@ -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 };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue