mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +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) :
|
||||
_uuid(),
|
||||
_command(command),
|
||||
_type(type),
|
||||
_pool(pool),
|
||||
|
@ -82,17 +83,7 @@ Assignment::Assignment(const QByteArray& packet) :
|
|||
QDataStream packetStream(packet);
|
||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||
|
||||
uchar assignmentType;
|
||||
packetStream >> assignmentType;
|
||||
_type = (Assignment::Type) assignmentType;
|
||||
|
||||
if (_command != Assignment::RequestCommand) {
|
||||
// read the GUID for this assignment
|
||||
packetStream >> _uuid;
|
||||
}
|
||||
|
||||
packetStream >> _pool;
|
||||
packetStream >> _payload;
|
||||
packetStream >> *this;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -157,14 +148,17 @@ QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
|||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
|
||||
out << (quint8) assignment._type;
|
||||
|
||||
// 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;
|
||||
out << (quint8) assignment._type << assignment._uuid << assignment._pool << assignment._payload;
|
||||
|
||||
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 QDataStream& operator<<(QDataStream &out, const Assignment& assignment);
|
||||
friend QDataStream& operator>>(QDataStream &in, Assignment& assignment);
|
||||
|
||||
protected:
|
||||
QUuid _uuid; /// the 16 byte UUID for this assignment
|
||||
|
|
Loading…
Reference in a new issue