mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
AK: Add to_string() for IPv4Address
This commit is contained in:
parent
73c291f5ae
commit
6163f607c0
Notes:
sideshowbarker
2024-07-17 08:36:27 +09:00
Author: https://github.com/stelar7 Commit: https://github.com/SerenityOS/serenity/commit/6163f607c0 Pull-request: https://github.com/SerenityOS/serenity/pull/18166 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/fdellwing ✅
@ -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 New Issue
Block a user