1/****************************************************************************
2**
3** Copyright (C) 2019 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef METATYPES_H
30#define METATYPES_H
31
32//
33// W A R N I N G
34// -------------
35//
36// This file is not part of the Qt API. It exists purely as an
37// implementation detail. This header file may change from version to
38// version without notice, or even be removed.
39//
40// We mean it.
41
42#include <QtCore/qstring.h>
43#include <QtCore/qstringlist.h>
44
45class MetaEnum
46{
47 QStringList m_keys;
48 QString m_name;
49 QString m_alias;
50 bool m_isFlag = false;
51
52public:
53 MetaEnum() = default;
54 explicit MetaEnum(QString name) : m_name(std::move(name)) {}
55
56 bool isValid() const { return !m_name.isEmpty(); }
57
58 QString name() const { return m_name; }
59 void setName(const QString &name) { m_name = name; }
60
61 QString alias() const { return m_alias; }
62 void setAlias(const QString &alias) { m_alias = alias; }
63
64 bool isFlag() const { return m_isFlag; }
65 void setIsFlag(bool isFlag) { m_isFlag = isFlag; }
66
67 void addKey(const QString &key) { m_keys.append(t: key); }
68 QStringList keys() const { return m_keys; }
69};
70
71class MetaMethod
72{
73public:
74 enum Type {
75 Signal,
76 Slot,
77 Method
78 };
79
80 enum Access {
81 Private,
82 Protected,
83 Public
84 };
85
86 MetaMethod() = default;
87 explicit MetaMethod(QString name, QString returnType = QString())
88 : m_name(std::move(name))
89 , m_returnType(std::move(returnType))
90 , m_methodType(Method)
91 , m_methodAccess(Public)
92 {}
93
94 QString methodName() const { return m_name; }
95 void setMethodName(const QString &name) { m_name = name; }
96
97 void setReturnType(const QString &type) { m_returnType = type; }
98
99 QStringList parameterNames() const { return m_paramNames; }
100 QStringList parameterTypes() const { return m_paramTypes; }
101 void addParameter(const QString &name, const QString &type)
102 {
103 m_paramNames.append(t: name);
104 m_paramTypes.append(t: type);
105 }
106
107 int methodType() const { return m_methodType; }
108 void setMethodType(Type methodType) { m_methodType = methodType; }
109
110 Access access() const { return m_methodAccess; }
111
112 int revision() const { return m_revision; }
113 void setRevision(int r) { m_revision = r; }
114
115private:
116 QString m_name;
117 QString m_returnType;
118 QStringList m_paramNames;
119 QStringList m_paramTypes;
120 Type m_methodType = Signal;
121 Access m_methodAccess = Private;
122 int m_revision = 0;
123};
124
125class ScopeTree;
126class MetaProperty
127{
128 QString m_propertyName;
129 QString m_typeName;
130 const ScopeTree *m_type = nullptr;
131 bool m_isList;
132 bool m_isWritable;
133 bool m_isPointer;
134 bool m_isAlias;
135 int m_revision;
136
137public:
138 MetaProperty(QString propertyName, QString typeName,
139 bool isList, bool isWritable, bool isPointer, bool isAlias,
140 int revision)
141 : m_propertyName(std::move(propertyName))
142 , m_typeName(std::move(typeName))
143 , m_isList(isList)
144 , m_isWritable(isWritable)
145 , m_isPointer(isPointer)
146 , m_isAlias(isAlias)
147 , m_revision(revision)
148 {}
149
150 QString propertyName() const { return m_propertyName; }
151 QString typeName() const { return m_typeName; }
152
153 void setType(const ScopeTree *type) { m_type = type; }
154 const ScopeTree *type() const { return m_type; }
155
156 bool isList() const { return m_isList; }
157 bool isWritable() const { return m_isWritable; }
158 bool isPointer() const { return m_isPointer; }
159 bool isAlias() const { return m_isAlias; }
160 int revision() const { return m_revision; }
161};
162
163#endif // METATYPES_H
164

source code of qtdeclarative/tools/qmllint/metatypes.h