Network/IpAddress: Add a parameter to exclude port from string
This commit is contained in:
parent
8e6ca9cb27
commit
69efb93671
|
|
@ -49,7 +49,7 @@ namespace Nz
|
||||||
|
|
||||||
inline IPv4 ToIPv4() const;
|
inline IPv4 ToIPv4() const;
|
||||||
inline IPv6 ToIPv6() const;
|
inline IPv6 ToIPv6() const;
|
||||||
std::string ToString() const;
|
std::string ToString(bool includesPort = true) const;
|
||||||
inline UInt32 ToUInt32() const;
|
inline UInt32 ToUInt32() const;
|
||||||
|
|
||||||
inline explicit operator bool() const;
|
inline explicit operator bool() const;
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,7 @@ namespace Nz
|
||||||
*
|
*
|
||||||
* \remark Produces a NazaraAssert if internal protocol is invalid (should never happen)
|
* \remark Produces a NazaraAssert if internal protocol is invalid (should never happen)
|
||||||
*/
|
*/
|
||||||
|
std::string IpAddress::ToString(bool includesPort) const
|
||||||
std::string IpAddress::ToString() const
|
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
|
@ -155,7 +154,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need brackets around our IPv6 address if we have a port
|
// We need brackets around our IPv6 address if we have a port
|
||||||
if (m_port != 0)
|
if (m_port != 0 && includesPort)
|
||||||
stream << '[';
|
stream << '[';
|
||||||
|
|
||||||
// IPv4-mapped IPv6?
|
// IPv4-mapped IPv6?
|
||||||
|
|
@ -195,12 +194,12 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_port != 0)
|
if (m_port != 0 && includesPort)
|
||||||
stream << ']';
|
stream << ']';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_port != 0)
|
if (m_port != 0 && includesPort)
|
||||||
stream << ':' << m_port;
|
stream << ':' << m_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue