added new versions of appendData for QString and QByteArray

This commit is contained in:
ZappoMan 2014-06-09 08:02:42 -07:00
parent 165984ff31
commit f6e5962593
2 changed files with 22 additions and 0 deletions

View file

@ -330,6 +330,22 @@ bool OctreePacketData::appendValue(bool value) {
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) {
const unsigned char* data = (const unsigned char*)&value;
int length = sizeof(value);

View file

@ -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
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
bool appendPosition(const glm::vec3& value);