mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
This commit is contained in:
parent
c4c4bbc5ba
commit
27f699ef0c
208 changed files with 1603 additions and 1621 deletions
|
@ -9,26 +9,26 @@ class [[gnu::packed]] IPv4Address
|
|||
{
|
||||
public:
|
||||
IPv4Address() {}
|
||||
IPv4Address(const byte data[4])
|
||||
IPv4Address(const u8 data[4])
|
||||
{
|
||||
m_data[0] = data[0];
|
||||
m_data[1] = data[1];
|
||||
m_data[2] = data[2];
|
||||
m_data[3] = data[3];
|
||||
}
|
||||
IPv4Address(byte a, byte b, byte c, byte d)
|
||||
IPv4Address(u8 a, u8 b, u8 c, u8 d)
|
||||
{
|
||||
m_data[0] = a;
|
||||
m_data[1] = b;
|
||||
m_data[2] = c;
|
||||
m_data[3] = d;
|
||||
}
|
||||
IPv4Address(NetworkOrdered<dword> address)
|
||||
: m_data_as_dword(address)
|
||||
IPv4Address(NetworkOrdered<u32> address)
|
||||
: m_data_as_u32(address)
|
||||
{
|
||||
}
|
||||
|
||||
byte operator[](int i) const
|
||||
u8 operator[](int i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < 4);
|
||||
return m_data[i];
|
||||
|
@ -39,13 +39,13 @@ public:
|
|||
return String::format("%u.%u.%u.%u", m_data[0], m_data[1], m_data[2], m_data[3]);
|
||||
}
|
||||
|
||||
bool operator==(const IPv4Address& other) const { return m_data_as_dword == other.m_data_as_dword; }
|
||||
bool operator!=(const IPv4Address& other) const { return m_data_as_dword != other.m_data_as_dword; }
|
||||
bool operator==(const IPv4Address& other) const { return m_data_as_u32 == other.m_data_as_u32; }
|
||||
bool operator!=(const IPv4Address& other) const { return m_data_as_u32 != other.m_data_as_u32; }
|
||||
|
||||
private:
|
||||
union {
|
||||
byte m_data[4];
|
||||
dword m_data_as_dword { 0 };
|
||||
u8 m_data[4];
|
||||
u32 m_data_as_u32 { 0 };
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue