mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
AK: Add to_string() for IPv4Address
This commit is contained in:
parent
73c291f5ae
commit
6163f607c0
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue