diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-08 17:19:35 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-08 17:19:35 +0200 |
commit | 3e175c9a96977f14a8adcf1b5a021ccb48f3b194 (patch) | |
tree | 73e705e124cebe98aa432568fba35c11b8f039d6 /LibGUI/GSocketAddress.h | |
parent | 93a4a4c5975d8fe0d8ed1191509664ef22342b5d (diff) | |
download | serenity-3e175c9a96977f14a8adcf1b5a021ccb48f3b194.zip |
LibGUI: Move GSocketAddress to its own file.
Diffstat (limited to 'LibGUI/GSocketAddress.h')
-rw-r--r-- | LibGUI/GSocketAddress.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/LibGUI/GSocketAddress.h b/LibGUI/GSocketAddress.h new file mode 100644 index 0000000000..c333e64a4e --- /dev/null +++ b/LibGUI/GSocketAddress.h @@ -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; +}; |