mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-30 19:54:41 +00:00
27 lines
457 B
C++
27 lines
457 B
C++
|
#include "package.h"
|
||
|
#include "streambase.h"
|
||
|
|
||
|
#include <QDataStream>
|
||
|
|
||
|
namespace ClientProtocol {
|
||
|
|
||
|
|
||
|
StreamBase::StreamBase() {}
|
||
|
|
||
|
bool StreamBase::fromBytes(const QByteArray &data) {
|
||
|
if (data.isEmpty())
|
||
|
return false;
|
||
|
|
||
|
QDataStream stream(data);
|
||
|
fromStream(stream);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
QByteArray StreamBase::toBytes() const {
|
||
|
QByteArray res;
|
||
|
QDataStream stream(&res, QIODevice::WriteOnly);
|
||
|
toStream(stream);
|
||
|
return res;
|
||
|
}
|
||
|
}
|