Akonadi

nodetree.h
1/*
2 SPDX-FileCopyrightText: 2017 Daniel Vrátil <dvratil@kde.og>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QList>
10#include <QMultiMap>
11
12class Node
13{
14public:
15 enum NodeType {
17 Class,
18 Ctor,
19 Enum,
20 EnumValue,
21 Property,
22 };
23
24 Node(NodeType type, Node *parent);
25 Node(const Node &) = delete;
26 Node(Node &&) = delete;
27 virtual ~Node();
28
29 Node &operator=(const Node &) = delete;
30 Node &operator=(Node &&) = delete;
31
32 NodeType type() const;
33 Node *parent() const;
34
35 void appendNode(Node *child);
36
37 const QList<Node const *> &children() const;
38
39protected:
40 Node *mParent;
41 QList<Node const *> mChildren;
42 NodeType mType;
43};
44
45class DocumentNode : public Node
46{
47public:
48 DocumentNode(int version);
49
50 int version() const;
51
52private:
53 int mVersion;
54};
55
56class PropertyNode;
57class ClassNode : public Node
58{
59public:
60 enum ClassType {
61 Invalid,
62 Class,
63 Command,
64 Response,
65 Notification,
66 };
67
68 ClassNode(const QString &name, ClassType type, DocumentNode *parent);
69 QString name() const;
70 ClassType classType() const;
71 QString className() const;
72 QString parentClassName() const;
73 QList<PropertyNode const *> properties() const;
74
75 static ClassType elementNameToType(QStringView name);
76
77private:
78 QString mName;
79 ClassType mClassType;
80};
81
82class CtorNode : public Node
83{
84public:
85 struct Argument {
86 QString name;
87 QString type;
88 QString defaultValue;
89
90 QString mVariableName() const
91 {
92 return QStringLiteral("m") + name[0].toUpper() + QStringView(name).mid(1);
93 }
94 };
95
96 CtorNode(const QList<Argument> &args, ClassNode *parent);
97 ~CtorNode() override;
98
99 QList<Argument> arguments() const;
100 void setArgumentType(const QString &name, const QString &type);
101
102private:
103 QList<Argument> mArgs;
104};
105
106class EnumNode : public Node
107{
108public:
109 enum EnumType {
110 TypeInvalid,
111 TypeEnum,
112 TypeFlag,
113 };
114
115 EnumNode(const QString &name, EnumType type, ClassNode *parent);
116
117 QString name() const;
118 EnumType enumType() const;
119 static EnumType elementNameToType(QStringView name);
120
121 QString flagsName() const;
122
123private:
124 QString mName;
125 EnumType mEnumType;
126};
127
128class EnumValueNode : public Node
129{
130public:
131 EnumValueNode(const QString &name, EnumNode *parent);
132
133 QString name() const;
134 void setValue(const QString &value);
135 QString value() const;
136
137private:
138 QString mName;
139 QString mValue;
140};
141
142class PropertyNode : public Node
143{
144public:
145 struct Setter {
148 QString append;
149 QString remove;
150 };
151
152 PropertyNode(const QString &name, const QString &type, ClassNode *parent);
153 ~PropertyNode() override;
154
155 QString type() const;
156 QString name() const;
157
158 void setDefaultValue(const QString &defaultValue);
159 QString defaultValue() const;
160
161 bool readOnly() const;
162 void setReadOnly(bool readOnly);
163
164 bool asReference() const;
165 void setAsReference(bool asReference);
166
167 bool isPointer() const;
168 bool isEnum() const;
169
170 QMultiMap<QString, QString> dependencies() const;
171 void addDependency(const QString &enumVar, const QString &enumValue);
172
173 Setter *setter() const;
174 void setSetter(Setter *setter);
175
176 QString mVariableName() const;
177 QString setterName() const;
178
179private:
180 QString mName;
181 QString mType;
182 QString mDefaultValue;
184 Setter *mSetter;
185 bool mReadOnly;
186 bool mAsReference;
187};
virtual QString type() const
Definition nodetree.cpp:47
QString name() const
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QString name(StandardAction id)
QString toUpper() const const
QStringView mid(qsizetype start, qsizetype length) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.