diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2017-10-26 10:52:35 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2017-11-02 07:50:14 +0000 |
commit | 489d2d4bd6c4602729f2dfe75f4a3b966b693c9c (patch) | |
tree | 86d9c7b4ff4afab6b1aa90d31e9fb31c03a6acfb /src/tools/ivigenerator/templates_frontend/struct.h.tpl | |
parent | 585bb90e6cf2098d42039fb04354a3223b9e10ef (diff) |
Add stream serialization functions for generated structs and enums5.10
Add stream operators and equality-operators for the struct template.
Change existing enum stream operators to check values outside of the enums range.
These are needed for serializing of types eg. when using generated types over QTRO.
Change-Id: I169b3d598b65eaae2de8562507a66ee996b81081
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Diffstat (limited to 'src/tools/ivigenerator/templates_frontend/struct.h.tpl')
-rw-r--r-- | src/tools/ivigenerator/templates_frontend/struct.h.tpl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/ivigenerator/templates_frontend/struct.h.tpl b/src/tools/ivigenerator/templates_frontend/struct.h.tpl index 84b8c4f..0438a87 100644 --- a/src/tools/ivigenerator/templates_frontend/struct.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/struct.h.tpl @@ -47,6 +47,7 @@ #include "{{module.module_name|lower}}module.h" #include <QObject> +#include <QDataStream> QT_BEGIN_NAMESPACE @@ -69,12 +70,21 @@ public: {% endif %} {% endfor %} + private: {% for field in struct.fields %} {{field|return_type}} m_{{field}}; {% endfor %} + + friend QDataStream &operator>>(QDataStream &stream, {{class}} &obj); }; +bool operator==(const {{class}} &left, const {{class}} &right) Q_DECL_NOTHROW; +bool operator!=(const {{class}} &left, const {{class}} &right) Q_DECL_NOTHROW; + +QDataStream &operator<<(QDataStream &stream, const {{class}} &obj); +QDataStream &operator>>(QDataStream &stream, {{class}} &obj); + QT_END_NAMESPACE Q_DECLARE_METATYPE({{class}}) |