AK: Add to_string() for IPv4Address

This commit is contained in:
stelar7 2023-04-03 18:50:11 +02:00 committed by Ali Mohammad Pur
parent 73c291f5ae
commit 6163f607c0
Notes: sideshowbarker 2024-07-17 08:36:27 +09:00

View file

@ -17,6 +17,7 @@
# include <Kernel/KString.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/String.h>
#endif
namespace AK {
@ -82,6 +83,15 @@ public:
octet(SubnetClass::B),
octet(SubnetClass::A));
}
ErrorOr<String> to_string() const
{
return String::formatted("{}.{}.{}.{}",
octet(SubnetClass::A),
octet(SubnetClass::B),
octet(SubnetClass::C),
octet(SubnetClass::D));
}
#endif
static Optional<IPv4Address> from_string(StringView string)