mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGUI: Move GSocketAddress to its own file.
This commit is contained in:
parent
93a4a4c597
commit
3e175c9a96
Notes:
sideshowbarker
2024-07-19 14:47:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3e175c9a969
2 changed files with 32 additions and 30 deletions
|
@ -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
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…
Reference in a new issue