mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibGUI: Move GSocketAddress to its own file.
This commit is contained in:
parent
93a4a4c597
commit
3e175c9a96
2 changed files with 32 additions and 30 deletions
|
@ -1,36 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibGUI/GIODevice.h>
|
#include <LibGUI/GIODevice.h>
|
||||||
#include <AK/AKString.h>
|
#include <LibGUI/GSocketAddress.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;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GNotifier;
|
class GNotifier;
|
||||||
|
|
||||||
|
|
31
LibGUI/GSocketAddress.h
Normal file
31
LibGUI/GSocketAddress.h
Normal 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;
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue