mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:37:49 +02:00
added new versions of appendData for QString and QByteArray
This commit is contained in:
parent
165984ff31
commit
f6e5962593
2 changed files with 22 additions and 0 deletions
|
@ -330,6 +330,22 @@ bool OctreePacketData::appendValue(bool value) {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OctreePacketData::appendValue(const QString& string) {
|
||||||
|
// TODO: make this a ByteCountCoded leading byte
|
||||||
|
uint16_t length = string.size() + 1; // include NULL
|
||||||
|
bool success = appendValue(length);
|
||||||
|
if (success) {
|
||||||
|
success = appendRawData((const unsigned char*)qPrintable(string), length);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OctreePacketData::appendValue(const QByteArray& bytes) {
|
||||||
|
bool success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OctreePacketData::appendPosition(const glm::vec3& value) {
|
bool OctreePacketData::appendPosition(const glm::vec3& value) {
|
||||||
const unsigned char* data = (const unsigned char*)&value;
|
const unsigned char* data = (const unsigned char*)&value;
|
||||||
int length = sizeof(value);
|
int length = sizeof(value);
|
||||||
|
|
|
@ -144,6 +144,12 @@ public:
|
||||||
|
|
||||||
/// appends a bool value to the end of the stream, may fail if new data stream is too long to fit in packet
|
/// appends a bool value to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
bool appendValue(bool value);
|
bool appendValue(bool value);
|
||||||
|
|
||||||
|
/// appends a string value to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
|
bool appendValue(const QString& string);
|
||||||
|
|
||||||
|
/// appends a QByteArray value to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
|
bool appendValue(const QByteArray& bytes);
|
||||||
|
|
||||||
/// appends a position to the end of the stream, may fail if new data stream is too long to fit in packet
|
/// appends a position to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
bool appendPosition(const glm::vec3& value);
|
bool appendPosition(const glm::vec3& value);
|
||||||
|
|
Loading…
Reference in a new issue