mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-20 13:29:42 +00:00
added implementation for the toBytes method of the HostAddress class.
This commit is contained in:
parent
30d5cc40ed
commit
dafcc6fbf0
@ -61,6 +61,21 @@ QString HostAddress::toString() const {
|
|||||||
return QHostAddress::toString() + ":" + QString::number(port());
|
return QHostAddress::toString() + ":" + QString::number(port());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray HostAddress::toBytes() const {
|
||||||
|
QByteArray res;
|
||||||
|
QDataStream stream(&res, QIODevice::WriteOnly);
|
||||||
|
operator <<(stream, *this);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HostAddress::fromBytes(const QByteArray &array) {
|
||||||
|
if (array.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QDataStream stream(array);
|
||||||
|
operator >>(stream, *this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream &operator >>(QDataStream &stream, HostAddress &address) {
|
QDataStream &operator >>(QDataStream &stream, HostAddress &address) {
|
||||||
stream >> static_cast<QHostAddress&>(address);
|
stream >> static_cast<QHostAddress&>(address);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user