From b0c47267d812b378042ae1262b987368569e4419 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 31 Aug 2020 09:24:17 +0200 Subject: [PATCH] QmlDesigner: Inline vector stream operators Task-number: QTCREATORBUG-24548 Change-Id: I01d1b6e12c04c4ea47279e3a5046a0d3e34a5c09 Reviewed-by: Thomas Hartmann --- .../qmlpuppet/commands/captureddatacommand.h | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h index f682c035e9f..449a9a2e4b2 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h @@ -29,10 +29,43 @@ #include "imagecontainer.h" -#include +#include namespace QmlDesigner { +template +QDataStream &operator<<(QDataStream &out, const std::vector &vector) +{ + out << quint64(vector.size()); + + for (auto &&entry : vector) + out << entry; + + return out; +} + +template +QDataStream &operator>>(QDataStream &in, std::vector &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 { public: