| 38 | } |
| 39 | |
| 40 | std::string IPAddress::toString() const { |
| 41 | if (isV6()) { |
| 42 | return boost::asio::ip::address_v6(std::get<IPAddressStore>(addr)).to_string(); |
| 43 | } else { |
| 44 | auto ip = std::get<uint32_t>(addr); |
| 45 | return format("%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | Optional<IPAddress> IPAddress::parse(std::string const& str) { |
| 50 | try { |
no test coverage detected