QHostAddress: add IPv6 address overloads that take const data
It has been a historical mistake that there wasn't a const overload. Change-Id: Ia0aac2f09e9245339951ffff13c8d8b70f206a99 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
08e45154fb
commit
aa246e487c
@ -414,6 +414,19 @@ QHostAddress::QHostAddress(quint8 *ip6Addr)
|
||||
setAddress(ip6Addr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.5
|
||||
Constructs a host address object with the IPv6 address \a ip6Addr.
|
||||
|
||||
\a ip6Addr must be a 16-byte array in network byte order (big
|
||||
endian).
|
||||
*/
|
||||
QHostAddress::QHostAddress(const quint8 *ip6Addr)
|
||||
: d(new QHostAddressPrivate)
|
||||
{
|
||||
setAddress(ip6Addr);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a host address object with the IPv6 address \a ip6Addr.
|
||||
*/
|
||||
@ -449,9 +462,9 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
|
||||
{
|
||||
#ifndef Q_OS_WINRT
|
||||
if (sockaddr->sa_family == AF_INET)
|
||||
setAddress(htonl(((sockaddr_in *)sockaddr)->sin_addr.s_addr));
|
||||
setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
|
||||
else if (sockaddr->sa_family == AF_INET6)
|
||||
setAddress(((qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
|
||||
setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
|
||||
#else
|
||||
Q_UNUSED(sockaddr)
|
||||
#endif
|
||||
@ -573,6 +586,20 @@ void QHostAddress::setAddress(quint8 *ip6Addr)
|
||||
d->setAddress(ip6Addr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 5.5
|
||||
|
||||
Set the IPv6 address specified by \a ip6Addr.
|
||||
|
||||
\a ip6Addr must be an array of 16 bytes in network byte order
|
||||
(high-order byte first).
|
||||
*/
|
||||
void QHostAddress::setAddress(const quint8 *ip6Addr)
|
||||
{
|
||||
d->setAddress(ip6Addr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
@ -610,9 +637,9 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr)
|
||||
#ifndef Q_OS_WINRT
|
||||
clear();
|
||||
if (sockaddr->sa_family == AF_INET)
|
||||
setAddress(htonl(((sockaddr_in *)sockaddr)->sin_addr.s_addr));
|
||||
setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
|
||||
else if (sockaddr->sa_family == AF_INET6)
|
||||
setAddress(((qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
|
||||
setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
|
||||
#else
|
||||
Q_UNUSED(sockaddr)
|
||||
#endif
|
||||
|
@ -75,7 +75,8 @@ public:
|
||||
|
||||
QHostAddress();
|
||||
explicit QHostAddress(quint32 ip4Addr);
|
||||
explicit QHostAddress(quint8 *ip6Addr);
|
||||
explicit QHostAddress(quint8 *ip6Addr); // ### Qt 6: remove me
|
||||
explicit QHostAddress(const quint8 *ip6Addr);
|
||||
explicit QHostAddress(const Q_IPV6ADDR &ip6Addr);
|
||||
explicit QHostAddress(const sockaddr *address);
|
||||
explicit QHostAddress(const QString &address);
|
||||
@ -87,7 +88,8 @@ public:
|
||||
QHostAddress &operator=(const QString &address);
|
||||
|
||||
void setAddress(quint32 ip4Addr);
|
||||
void setAddress(quint8 *ip6Addr);
|
||||
void setAddress(quint8 *ip6Addr); // ### Qt 6: remove me
|
||||
void setAddress(const quint8 *ip6Addr);
|
||||
void setAddress(const Q_IPV6ADDR &ip6Addr);
|
||||
void setAddress(const sockaddr *address);
|
||||
bool setAddress(const QString &address);
|
||||
|
Loading…
Reference in New Issue
Block a user