LibGUI: Move GSocketAddress to its own file.

This commit is contained in:
Andreas Kling 2019-04-08 17:19:35 +02:00
parent 93a4a4c597
commit 3e175c9a96
Notes: sideshowbarker 2024-07-19 14:47:30 +09:00
2 changed files with 32 additions and 30 deletions

View file

@ -1,36 +1,7 @@
#pragma once
#include <LibGUI/GIODevice.h>
#include <AK/AKString.h>
#include <Kernel/Net/IPv4.h>
class GSocketAddress {
public:
enum class Type { Invalid, IPv4, Local };
GSocketAddress() { }
GSocketAddress(const IPv4Address& address)
: m_type(Type::IPv4)
, m_ipv4_address(address)
{
}
Type type() const { return m_type; }
bool is_valid() const { return m_type != Type::Invalid; }
IPv4Address ipv4_address() const { return m_ipv4_address; }
String to_string() const
{
switch (m_type) {
case Type::IPv4: return m_ipv4_address.to_string();
default: return "[GSocketAddress]";
}
}
private:
Type m_type { Type::Invalid };
IPv4Address m_ipv4_address;
};
#include <LibGUI/GSocketAddress.h>
class GNotifier;

31
LibGUI/GSocketAddress.h Normal file
View file

@ -0,0 +1,31 @@
#pragma once
#include <Kernel/Net/IPv4.h>
class GSocketAddress {
public:
enum class Type { Invalid, IPv4, Local };
GSocketAddress() { }
GSocketAddress(const IPv4Address& address)
: m_type(Type::IPv4)
, m_ipv4_address(address)
{
}
Type type() const { return m_type; }
bool is_valid() const { return m_type != Type::Invalid; }
IPv4Address ipv4_address() const { return m_ipv4_address; }
String to_string() const
{
switch (m_type) {
case Type::IPv4: return m_ipv4_address.to_string();
default: return "[GSocketAddress]";
}
}
private:
Type m_type { Type::Invalid };
IPv4Address m_ipv4_address;
};