add QByteArray data uppacking

This commit is contained in:
Seth Alves 2015-05-26 13:18:25 -07:00
parent d71921fd03
commit ed6fdcfb31
2 changed files with 10 additions and 0 deletions

View file

@ -573,3 +573,12 @@ int OctreePacketData::uppackDataFromBytes(const unsigned char* dataBytes, xColor
result.blue = dataBytes[BLUE_INDEX];
return sizeof(rgbColor);
}
int OctreePacketData::uppackDataFromBytes(const unsigned char* dataBytes, QByteArray& result) {
uint16_t length;
memcpy(&length, dataBytes, sizeof(length));
dataBytes += sizeof(length);
QByteArray value((const char*)dataBytes, length);
result = value;
return sizeof(length) + length;
}

View file

@ -240,6 +240,7 @@ public:
static int uppackDataFromBytes(const unsigned char* dataBytes, QString& result);
static int uppackDataFromBytes(const unsigned char* dataBytes, QUuid& result);
static int uppackDataFromBytes(const unsigned char* dataBytes, xColor& result);
static int uppackDataFromBytes(const unsigned char* dataBytes, QByteArray& result);
private:
/// appends raw bytes, might fail if byte would cause packet to be too large