QmlDesigner: Inline vector stream operators

Task-number: QTCREATORBUG-24548
Change-Id: I01d1b6e12c04c4ea47279e3a5046a0d3e34a5c09
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2020-08-31 09:24:17 +02:00
parent 1bc03df197
commit b0c47267d8

View File

@@ -29,10 +29,43 @@
#include "imagecontainer.h" #include "imagecontainer.h"
#include <utils/smallstringio.h> #include <vector>
namespace QmlDesigner { namespace QmlDesigner {
template<typename Type>
QDataStream &operator<<(QDataStream &out, const std::vector<Type> &vector)
{
out << quint64(vector.size());
for (auto &&entry : vector)
out << entry;
return out;
}
template<typename Type>
QDataStream &operator>>(QDataStream &in, std::vector<Type> &vector)
{
vector.clear();
quint64 size;
in >> size;
vector.reserve(size);
for (quint64 i = 0; i < size; ++i) {
Type entry;
in >> entry;
vector.push_back(std::move(entry));
}
return in;
}
class CapturedDataCommand class CapturedDataCommand
{ {
public: public: