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

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