MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetAddressFormatString

Function GetAddressFormatString

src/network/core/address.cpp:81–88  ·  view source on GitHub ↗

* Helper to get the formatting string of an address for a given family. * @param family The family to get the address format for. * @param with_family Whether to add the familty to the address (e.g. IPv4). * @return The format string for the address. */

Source from the content-addressed store, hash-verified

79 * @return The format string for the address.
80 */
81static std::string_view GetAddressFormatString(uint16_t family, bool with_family)
82{
83 switch (family) {
84 case AF_INET: return with_family ? "{}:{} (IPv4)" : "{}:{}";
85 case AF_INET6: return with_family ? "[{}]:{} (IPv6)" : "[{}]:{}";
86 default: return with_family ? "{}:{} (IPv?)" : "{}:{}";
87 }
88}
89
90/**
91 * Get the address as a string, e.g. 127.0.0.1:12345.

Callers 1

GetAddressAsStringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected