1// Copyright (C) 2021 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QREMOTEOBJECTCONTAINERS_P_H
5#define QREMOTEOBJECTCONTAINERS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qassociativeiterable.h>
19#include <QtCore/qsequentialiterable.h>
20#include <QtCore/qvariant.h>
21#include <QtCore/private/qglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QtROSequentialContainer : public QVariantList
26{
27public:
28 QtROSequentialContainer() = default;
29 QtROSequentialContainer(const QSequentialIterable &lst)
30 {
31 m_valueType = lst.metaContainer().valueMetaType();
32 reserve(asize: lst.size());
33 for (const auto v : lst)
34 append(t: v);
35 }
36 void setValueType(const QByteArray &valueTypeName)
37 {
38 m_valueTypeName = valueTypeName;
39 m_valueType = QMetaType::fromName(name: valueTypeName.constData());
40 clear();
41 }
42
43 QMetaType m_valueType;
44 QByteArray m_typeName, m_valueTypeName;
45};
46
47QDataStream &operator>>(QDataStream &ds, QtROSequentialContainer &p);
48
49QDataStream &operator<<(QDataStream &ds, const QtROSequentialContainer &p);
50
51class QtROAssociativeContainer : public QVariantMap
52{
53public:
54 QtROAssociativeContainer() = default;
55 QtROAssociativeContainer(const QAssociativeIterable &map)
56 {
57 m_keyType = map.metaContainer().keyMetaType();
58 m_valueType = map.metaContainer().mappedMetaType();
59 m_keys.reserve(asize: map.size());
60 QAssociativeIterable::const_iterator iter = map.begin();
61 const QAssociativeIterable::const_iterator end = map.end();
62 for ( ; iter != end; ++iter) {
63 m_keys.append(t: iter.key());
64 insert(key: iter.key().toString(), value: iter.value());
65 }
66 }
67 void setTypes(const QByteArray &keyTypeName, const QByteArray &valueTypeName)
68 {
69 m_keyTypeName = keyTypeName;
70 m_keyType = QMetaType::fromName(name: keyTypeName.constData());
71 m_valueTypeName = valueTypeName;
72 m_valueType = QMetaType::fromName(name: valueTypeName.constData());
73 clear();
74 m_keys.clear();
75 }
76
77 QMetaType m_keyType, m_valueType;
78 QByteArray m_typeName, m_keyTypeName, m_valueTypeName;
79 QVariantList m_keys; // Map uses QString for key, this doesn't lose information for proxy
80};
81
82QDataStream &operator>>(QDataStream &ds, QtROAssociativeContainer &p);
83
84QDataStream &operator<<(QDataStream &ds, const QtROAssociativeContainer &p);
85
86QT_END_NAMESPACE
87
88#endif // QREMOTEOBJECTCONTAINERS_P_H
89

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtremoteobjects/src/remoteobjects/qremoteobjectcontainers_p.h