mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 20:39:55 +02:00
Fixing template specialization compilation error on gcc/clang
This commit is contained in:
parent
98e0688e98
commit
600e9cbf52
1 changed files with 46 additions and 45 deletions
|
@ -26,54 +26,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void readValue(T& result) {
|
inline void readValue(T& result) {
|
||||||
Q_ASSERT(remaining() >= sizeof(T));
|
Q_ASSERT(remaining() >= sizeof(T));
|
||||||
memcpy(&result, _data + _offset, sizeof(T));
|
memcpy(&result, _data + _offset, sizeof(T));
|
||||||
_offset += sizeof(T);
|
_offset += sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
inline void readUuid(QUuid& result) {
|
||||||
void readValue<quat>(quat& result) {
|
|
||||||
size_t advance = unpackOrientationQuatFromBytes(_data + _offset, result);
|
|
||||||
_offset += advance;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void readValue<QString>(QString& result) {
|
|
||||||
uint16_t length; readValue(length);
|
|
||||||
result = QString((const char*)_data + _offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void readValue<QUuid>(QUuid& result) {
|
|
||||||
uint16_t length; readValue(length);
|
|
||||||
Q_ASSERT(16 == length);
|
|
||||||
readUuid(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void readValue<xColor>(xColor& result) {
|
|
||||||
readValue(result.red);
|
|
||||||
readValue(result.blue);
|
|
||||||
readValue(result.green);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void readValue<QVector<glm::vec3>>(QVector<glm::vec3>& result) {
|
|
||||||
uint16_t length; readValue(length);
|
|
||||||
result.resize(length);
|
|
||||||
memcpy(result.data(), _data + _offset, sizeof(glm::vec3) * length);
|
|
||||||
_offset += sizeof(glm::vec3) * length;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void readValue<QByteArray>(QByteArray& result) {
|
|
||||||
uint16_t length; readValue(length);
|
|
||||||
result = QByteArray((char*)_data + _offset, (int)length);
|
|
||||||
_offset += length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void readUuid(QUuid& result) {
|
|
||||||
readValue(result.data1);
|
readValue(result.data1);
|
||||||
readValue(result.data2);
|
readValue(result.data2);
|
||||||
readValue(result.data3);
|
readValue(result.data3);
|
||||||
|
@ -84,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void readFlags(PropertyFlags<T>& result) {
|
inline void readFlags(PropertyFlags<T>& result) {
|
||||||
// FIXME doing heap allocation
|
// FIXME doing heap allocation
|
||||||
QByteArray encoded((const char*)(_data + _offset), remaining());
|
QByteArray encoded((const char*)(_data + _offset), remaining());
|
||||||
result.decode(encoded);
|
result.decode(encoded);
|
||||||
|
@ -92,7 +51,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void readCompressedCount(T& result) {
|
inline void readCompressedCount(T& result) {
|
||||||
// FIXME switch to a heapless implementation as soon as Brad provides it.
|
// FIXME switch to a heapless implementation as soon as Brad provides it.
|
||||||
QByteArray encoded((const char*)(_data + _offset), std::min(sizeof(T) << 1, remaining()));
|
QByteArray encoded((const char*)(_data + _offset), std::min(sizeof(T) << 1, remaining()));
|
||||||
ByteCountCoded<T> codec = encoded;
|
ByteCountCoded<T> codec = encoded;
|
||||||
|
@ -120,4 +79,46 @@ private:
|
||||||
const size_t _size;
|
const size_t _size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue<quat>(quat& result) {
|
||||||
|
size_t advance = unpackOrientationQuatFromBytes(_data + _offset, result);
|
||||||
|
_offset += advance;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue(QString& result) {
|
||||||
|
uint16_t length; readValue(length);
|
||||||
|
result = QString((const char*)_data + _offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue(QUuid& result) {
|
||||||
|
uint16_t length; readValue(length);
|
||||||
|
Q_ASSERT(16 == length);
|
||||||
|
readUuid(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue(xColor& result) {
|
||||||
|
readValue(result.red);
|
||||||
|
readValue(result.blue);
|
||||||
|
readValue(result.green);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue(QVector<glm::vec3>& result) {
|
||||||
|
uint16_t length; readValue(length);
|
||||||
|
result.resize(length);
|
||||||
|
memcpy(result.data(), _data + _offset, sizeof(glm::vec3) * length);
|
||||||
|
_offset += sizeof(glm::vec3) * length;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BufferParser::readValue(QByteArray& result) {
|
||||||
|
uint16_t length; readValue(length);
|
||||||
|
result = QByteArray((char*)_data + _offset, (int)length);
|
||||||
|
_offset += length;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue