mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 00:29:40 +02:00
Allow streaming QVariantLists.
This commit is contained in:
parent
839e5e085c
commit
72b002ddc4
2 changed files with 26 additions and 2 deletions
|
@ -236,6 +236,27 @@ Bitstream& Bitstream::operator>>(QVariant& value) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
Bitstream& Bitstream::operator<<(const QVariantList& value) {
|
||||
*this << value.size();
|
||||
foreach (const QVariant& entry, value) {
|
||||
*this << entry;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bitstream& Bitstream::operator>>(QVariantList& value) {
|
||||
int size;
|
||||
*this >> size;
|
||||
value.clear();
|
||||
value.reserve(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
QVariant entry;
|
||||
*this >> entry;
|
||||
value.append(entry);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bitstream& Bitstream::operator<<(const QObject* object) {
|
||||
if (!object) {
|
||||
_metaObjectStreamer << NULL;
|
||||
|
|
|
@ -231,6 +231,9 @@ public:
|
|||
Bitstream& operator<<(const QVariant& value);
|
||||
Bitstream& operator>>(QVariant& value);
|
||||
|
||||
Bitstream& operator<<(const QVariantList& value);
|
||||
Bitstream& operator>>(QVariantList& value);
|
||||
|
||||
Bitstream& operator<<(const QObject* object);
|
||||
Bitstream& operator>>(QObject*& object);
|
||||
|
||||
|
@ -287,8 +290,8 @@ public:
|
|||
#define REGISTER_SIMPLE_TYPE_STREAMER(x) static int x##Streamer = \
|
||||
Bitstream::registerTypeStreamer(QMetaType::type(#x), new SimpleTypeStreamer<x>());
|
||||
|
||||
/// Declares the metatype and the streaming operators. The last line
|
||||
/// ensures that the generated file will be included in the link phase.
|
||||
/// Declares the metatype and the streaming operators. The last lines
|
||||
/// ensure that the generated file will be included in the link phase.
|
||||
#define STRINGIFY(x) #x
|
||||
#define DECLARE_STREAMABLE_METATYPE(X) Q_DECLARE_METATYPE(X) \
|
||||
Bitstream& operator<<(Bitstream& out, const X& obj); \
|
||||
|
|
Loading…
Reference in a new issue