Akonadi

nodetree.h
1 /*
2  Copyright (c) 2017 Daniel Vrátil <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef NODETREE_H
21 #define NODETREE_H
22 
23 #include <QVector>
24 #include <QMultiMap>
25 
26 class Node
27 {
28 public:
29  enum NodeType {
30  Document,
31  Class,
32  Ctor,
33  Enum,
34  EnumValue,
35  Property
36  };
37 
38  Node(NodeType type, Node *parent);
39  Node(const Node &) = delete;
40  Node(Node &&) = delete;
41  virtual ~Node();
42 
43  Node &operator=(const Node &) = delete;
44  Node &operator=(Node &&) = delete;
45 
46  NodeType type() const;
47  Node *parent() const;
48 
49  void appendNode(Node *child);
50 
51  const QVector<Node const *> &children() const;
52 
53 protected:
54  Node *mParent;
55  QVector<Node const *> mChildren;
56  NodeType mType;
57 };
58 
59 
60 
61 class DocumentNode : public Node
62 {
63 public:
64  DocumentNode(int version);
65 
66  int version() const;
67 
68 private:
69  int mVersion;
70 };
71 
72 class PropertyNode;
73 class ClassNode : public Node
74 {
75 public:
76  enum ClassType {
77  Invalid,
78  Class,
79  Command,
80  Response,
81  Notification
82  };
83 
84  ClassNode(const QString &name, ClassType type, DocumentNode *parent);
85  QString name() const;
86  ClassType classType() const;
87  QString className() const;
88  QString parentClassName() const;
90 
91  static ClassType elementNameToType(const QStringRef &name);
92 
93 private:
94  QString mName;
95  ClassType mClassType;
96 };
97 
98 
99 class CtorNode : public Node
100 {
101 public:
102  struct Argument {
103  QString name;
104  QString type;
105  QString defaultValue;
106 
107  QString mVariableName() const
108  {
109  return QStringLiteral("m") + name[0].toUpper() + name.midRef(1);
110  }
111  };
112 
113  CtorNode(const QVector<Argument> &args, ClassNode *parent);
114  ~CtorNode();
115 
116  QVector<Argument> arguments() const;
117  void setArgumentType(const QString &name, const QString &type);
118 
119 private:
120  QVector<Argument> mArgs;
121 };
122 
123 
124 class EnumNode : public Node
125 {
126 public:
127  enum EnumType {
128  TypeInvalid,
129  TypeEnum,
130  TypeFlag
131  };
132 
133  EnumNode(const QString &name, EnumType type, ClassNode *parent);
134 
135  QString name() const;
136  EnumType enumType() const;
137 
138  static EnumType elementNameToType(const QStringRef &name);
139 
140 private:
141  QString mName;
142  EnumType mEnumType;
143 };
144 
145 
146 class EnumValueNode : public Node
147 {
148 public:
149  EnumValueNode(const QString &name, EnumNode *parent);
150 
151  QString name() const;
152  void setValue(const QString &value);
153  QString value() const;
154 
155 private:
156  QString mName;
157  QString mValue;
158 };
159 
160 
161 class PropertyNode : public Node
162 {
163 public:
164  struct Setter {
165  QString name;
166  QString type;
167  QString append;
168  QString remove;
169  };
170 
171  PropertyNode(const QString &name, const QString &type, ClassNode *parent);
172  ~PropertyNode();
173 
174  QString type() const;
175  QString name() const;
176 
177  void setDefaultValue(const QString &defaultValue);
178  QString defaultValue() const;
179 
180  bool readOnly() const;
181  void setReadOnly(bool readOnly);
182 
183  bool asReference() const;
184  void setAsReference(bool asReference);
185 
186  bool isPointer() const;
187 
188  QMultiMap<QString, QString> dependencies() const;
189  void addDependency(const QString &enumVar, const QString &enumValue);
190 
191  Setter *setter() const;
192  void setSetter(Setter *setter);
193 
194  QString mVariableName() const;
195  QString setterName() const;
196 
197 private:
198  QString mName;
199  QString mType;
200  QString mDefaultValue;
202  Setter *mSetter;
203  bool mReadOnly;
204  bool mAsReference;
205 };
206 
207 #endif // NODETREE_H
Type type(const QString &mimeType)
QString toUpper() const const
QString name(const QVariant &location)
KGuiItem properties()
QStringRef midRef(int position, int n) const const
Property
KDB_EXPORT KDbVersionInfo version()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.