mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 19:03:07 +02:00
add QDataStream >> operator to Assignment
This commit is contained in:
parent
fe192ca2de
commit
740d11027c
2 changed files with 14 additions and 19 deletions
|
@ -52,6 +52,7 @@ Assignment::Assignment() :
|
||||||
}
|
}
|
||||||
|
|
||||||
Assignment::Assignment(Assignment::Command command, Assignment::Type type, const QString& pool, Assignment::Location location) :
|
Assignment::Assignment(Assignment::Command command, Assignment::Type type, const QString& pool, Assignment::Location location) :
|
||||||
|
_uuid(),
|
||||||
_command(command),
|
_command(command),
|
||||||
_type(type),
|
_type(type),
|
||||||
_pool(pool),
|
_pool(pool),
|
||||||
|
@ -82,17 +83,7 @@ Assignment::Assignment(const QByteArray& packet) :
|
||||||
QDataStream packetStream(packet);
|
QDataStream packetStream(packet);
|
||||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
uchar assignmentType;
|
packetStream >> *this;
|
||||||
packetStream >> assignmentType;
|
|
||||||
_type = (Assignment::Type) assignmentType;
|
|
||||||
|
|
||||||
if (_command != Assignment::RequestCommand) {
|
|
||||||
// read the GUID for this assignment
|
|
||||||
packetStream >> _uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
packetStream >> _pool;
|
|
||||||
packetStream >> _payload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -157,14 +148,17 @@ QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
|
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
|
||||||
out << (quint8) assignment._type;
|
out << (quint8) assignment._type << assignment._uuid << assignment._pool << assignment._payload;
|
||||||
|
|
||||||
// pack the UUID for this assignment, if this is an assignment create or deploy
|
|
||||||
if (assignment._command != Assignment::RequestCommand) {
|
|
||||||
out << assignment._uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
out << assignment._pool << assignment._payload;
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDataStream& operator>>(QDataStream &in, Assignment& assignment) {
|
||||||
|
quint8 packedType;
|
||||||
|
in >> packedType;
|
||||||
|
assignment._type = (Assignment::Type) packedType;
|
||||||
|
|
||||||
|
in >> assignment._uuid >> assignment._pool >> assignment._payload;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug debug, const Assignment& assignment);
|
friend QDebug operator<<(QDebug debug, const Assignment& assignment);
|
||||||
friend QDataStream& operator<<(QDataStream &out, const Assignment& assignment);
|
friend QDataStream& operator<<(QDataStream &out, const Assignment& assignment);
|
||||||
|
friend QDataStream& operator>>(QDataStream &in, Assignment& assignment);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUuid _uuid; /// the 16 byte UUID for this assignment
|
QUuid _uuid; /// the 16 byte UUID for this assignment
|
||||||
|
|
Loading…
Reference in a new issue