1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*
|
---|
43 | node.h
|
---|
44 | */
|
---|
45 |
|
---|
46 | #ifndef NODE_H
|
---|
47 | #define NODE_H
|
---|
48 |
|
---|
49 | #include <qdir.h>
|
---|
50 | #include <qmap.h>
|
---|
51 | #include <qpair.h>
|
---|
52 | #include <qstringlist.h>
|
---|
53 |
|
---|
54 | #include "codechunk.h"
|
---|
55 | #include "doc.h"
|
---|
56 | #include "location.h"
|
---|
57 | #include "text.h"
|
---|
58 |
|
---|
59 | QT_BEGIN_NAMESPACE
|
---|
60 |
|
---|
61 | class InnerNode;
|
---|
62 |
|
---|
63 | class Node
|
---|
64 | {
|
---|
65 | public:
|
---|
66 | enum Type {
|
---|
67 | Namespace,
|
---|
68 | Class,
|
---|
69 | Fake,
|
---|
70 | Enum,
|
---|
71 | Typedef,
|
---|
72 | Function,
|
---|
73 | Property,
|
---|
74 | Variable,
|
---|
75 | Target
|
---|
76 | };
|
---|
77 |
|
---|
78 | enum Access { Public, Protected, Private };
|
---|
79 |
|
---|
80 | enum Status {
|
---|
81 | Compat,
|
---|
82 | Obsolete,
|
---|
83 | Deprecated,
|
---|
84 | Preliminary,
|
---|
85 | Commendable,
|
---|
86 | Main,
|
---|
87 | Internal
|
---|
88 | }; // don't reorder thisw enum
|
---|
89 |
|
---|
90 | enum ThreadSafeness {
|
---|
91 | UnspecifiedSafeness,
|
---|
92 | NonReentrant,
|
---|
93 | Reentrant,
|
---|
94 | ThreadSafe
|
---|
95 | };
|
---|
96 |
|
---|
97 | enum LinkType {
|
---|
98 | StartLink,
|
---|
99 | NextLink,
|
---|
100 | PreviousLink,
|
---|
101 | ContentsLink,
|
---|
102 | IndexLink /*,
|
---|
103 | GlossaryLink,
|
---|
104 | CopyrightLink,
|
---|
105 | ChapterLink,
|
---|
106 | SectionLink,
|
---|
107 | SubsectionLink,
|
---|
108 | AppendixLink */
|
---|
109 | };
|
---|
110 |
|
---|
111 | virtual ~Node();
|
---|
112 |
|
---|
113 | void setAccess(Access access) { acc = access; }
|
---|
114 | void setLocation(const Location& location) { loc = location; }
|
---|
115 | void setDoc(const Doc& doc, bool replace = false);
|
---|
116 | void setStatus(Status status) { sta = status; }
|
---|
117 | void setThreadSafeness(ThreadSafeness safeness) { saf = safeness; }
|
---|
118 | void setSince(const QString &since) { sinc = since; }
|
---|
119 | void setRelates(InnerNode *pseudoParent);
|
---|
120 | void setModuleName(const QString &module) { mod = module; }
|
---|
121 | void setLink(LinkType linkType, const QString &link, const QString &desc);
|
---|
122 | void setUrl(const QString &url);
|
---|
123 | void setTemplateStuff(const QString &templateStuff) { tpl = templateStuff; }
|
---|
124 |
|
---|
125 | virtual bool isInnerNode() const = 0;
|
---|
126 | Type type() const { return typ; }
|
---|
127 | InnerNode *parent() const { return par; }
|
---|
128 | InnerNode *relates() const { return rel; }
|
---|
129 | const QString& name() const { return nam; }
|
---|
130 | QMap<LinkType, QPair<QString,QString> > links() const { return linkMap; }
|
---|
131 | QString moduleName() const;
|
---|
132 | QString url() const;
|
---|
133 |
|
---|
134 | Access access() const { return acc; }
|
---|
135 | const Location& location() const { return loc; }
|
---|
136 | const Doc& doc() const { return d; }
|
---|
137 | Status status() const { return sta; }
|
---|
138 | Status inheritedStatus() const;
|
---|
139 | ThreadSafeness threadSafeness() const;
|
---|
140 | ThreadSafeness inheritedThreadSafeness() const;
|
---|
141 | QString since() const { return sinc; }
|
---|
142 | QString templateStuff() const { return tpl; }
|
---|
143 |
|
---|
144 | void clearRelated() { rel = 0; }
|
---|
145 |
|
---|
146 | QString fileBase() const;
|
---|
147 |
|
---|
148 | protected:
|
---|
149 | Node(Type type, InnerNode *parent, const QString& name);
|
---|
150 |
|
---|
151 | private:
|
---|
152 | #ifdef Q_WS_WIN
|
---|
153 | Type typ;
|
---|
154 | Access acc;
|
---|
155 | Status sta;
|
---|
156 | ThreadSafeness saf;
|
---|
157 | #else
|
---|
158 | Type typ : 4;
|
---|
159 | Access acc : 2;
|
---|
160 | Status sta : 3;
|
---|
161 | ThreadSafeness saf : 2;
|
---|
162 | #endif
|
---|
163 | InnerNode *par;
|
---|
164 | InnerNode *rel;
|
---|
165 | QString nam;
|
---|
166 | Location loc;
|
---|
167 | Doc d;
|
---|
168 | QMap<LinkType, QPair<QString, QString> > linkMap;
|
---|
169 | QString mod;
|
---|
170 | QString u;
|
---|
171 | QString sinc;
|
---|
172 | QString tpl;
|
---|
173 | };
|
---|
174 |
|
---|
175 | class FunctionNode;
|
---|
176 | class EnumNode;
|
---|
177 |
|
---|
178 | typedef QList<Node *> NodeList;
|
---|
179 |
|
---|
180 | class InnerNode : public Node
|
---|
181 | {
|
---|
182 | public:
|
---|
183 | ~InnerNode();
|
---|
184 |
|
---|
185 | Node *findNode(const QString& name);
|
---|
186 | Node *findNode(const QString& name, Type type);
|
---|
187 | FunctionNode *findFunctionNode(const QString& name);
|
---|
188 | FunctionNode *findFunctionNode(const FunctionNode *clone);
|
---|
189 | void addInclude(const QString &include);
|
---|
190 | void setIncludes(const QStringList &includes);
|
---|
191 | void setOverload(const FunctionNode *func, bool overlode);
|
---|
192 | void normalizeOverloads();
|
---|
193 | void makeUndocumentedChildrenInternal();
|
---|
194 | void deleteChildren();
|
---|
195 | void removeFromRelated();
|
---|
196 |
|
---|
197 | virtual bool isInnerNode() const;
|
---|
198 | const Node *findNode(const QString& name) const;
|
---|
199 | const Node *findNode(const QString& name, Type type) const;
|
---|
200 | const FunctionNode *findFunctionNode(const QString& name) const;
|
---|
201 | const FunctionNode *findFunctionNode(const FunctionNode *clone) const;
|
---|
202 | const EnumNode *findEnumNodeForValue(const QString &enumValue) const;
|
---|
203 | const NodeList & childNodes() const { return children; }
|
---|
204 | const NodeList & relatedNodes() const { return related; }
|
---|
205 | int overloadNumber(const FunctionNode *func) const;
|
---|
206 | int numOverloads(const QString& funcName) const;
|
---|
207 | NodeList overloads(const QString &funcName) const;
|
---|
208 | const QStringList& includes() const { return inc; }
|
---|
209 |
|
---|
210 | protected:
|
---|
211 | InnerNode(Type type, InnerNode *parent, const QString& name);
|
---|
212 |
|
---|
213 | private:
|
---|
214 | friend class Node;
|
---|
215 |
|
---|
216 | static bool isSameSignature(const FunctionNode *f1, const FunctionNode *f2);
|
---|
217 | void addChild(Node *child);
|
---|
218 | void removeChild(Node *child);
|
---|
219 | void removeRelated(Node *pseudoChild);
|
---|
220 |
|
---|
221 | QStringList inc;
|
---|
222 | NodeList children;
|
---|
223 | NodeList enumChildren;
|
---|
224 | NodeList related;
|
---|
225 | QMap<QString, Node *> childMap;
|
---|
226 | QMap<QString, Node *> primaryFunctionMap;
|
---|
227 | QMap<QString, NodeList> secondaryFunctionMap;
|
---|
228 | };
|
---|
229 |
|
---|
230 | class LeafNode : public Node
|
---|
231 | {
|
---|
232 | public:
|
---|
233 | LeafNode();
|
---|
234 |
|
---|
235 | virtual bool isInnerNode() const;
|
---|
236 |
|
---|
237 | protected:
|
---|
238 | LeafNode(Type type, InnerNode *parent, const QString& name);
|
---|
239 | };
|
---|
240 |
|
---|
241 | class NamespaceNode : public InnerNode
|
---|
242 | {
|
---|
243 | public:
|
---|
244 | NamespaceNode(InnerNode *parent, const QString& name);
|
---|
245 | };
|
---|
246 |
|
---|
247 | class ClassNode;
|
---|
248 |
|
---|
249 | struct RelatedClass
|
---|
250 | {
|
---|
251 | RelatedClass() { }
|
---|
252 | RelatedClass(Node::Access access0,
|
---|
253 | ClassNode* node0,
|
---|
254 | const QString& dataTypeWithTemplateArgs0 = "")
|
---|
255 | : access(access0),
|
---|
256 | node(node0),
|
---|
257 | dataTypeWithTemplateArgs(dataTypeWithTemplateArgs0) { }
|
---|
258 |
|
---|
259 | Node::Access access;
|
---|
260 | ClassNode* node;
|
---|
261 | QString dataTypeWithTemplateArgs;
|
---|
262 | };
|
---|
263 |
|
---|
264 | class ClassNode : public InnerNode
|
---|
265 | {
|
---|
266 | public:
|
---|
267 | ClassNode(InnerNode *parent, const QString& name);
|
---|
268 |
|
---|
269 | void addBaseClass(Access access,
|
---|
270 | ClassNode *node,
|
---|
271 | const QString &dataTypeWithTemplateArgs = "");
|
---|
272 | void fixBaseClasses();
|
---|
273 |
|
---|
274 | const QList<RelatedClass> &baseClasses() const { return bas; }
|
---|
275 | const QList<RelatedClass> &derivedClasses() const { return der; }
|
---|
276 |
|
---|
277 | bool hideFromMainList() const { return hidden; }
|
---|
278 | void setHideFromMainList(bool value) { hidden = value; }
|
---|
279 |
|
---|
280 | QString serviceName() const { return sname; }
|
---|
281 | void setServiceName(const QString& value) { sname = value; }
|
---|
282 |
|
---|
283 | private:
|
---|
284 | QList<RelatedClass> bas;
|
---|
285 | QList<RelatedClass> der;
|
---|
286 | bool hidden;
|
---|
287 | QString sname;
|
---|
288 | };
|
---|
289 |
|
---|
290 | class FakeNode : public InnerNode
|
---|
291 | {
|
---|
292 | public:
|
---|
293 | enum SubType {
|
---|
294 | Example,
|
---|
295 | HeaderFile,
|
---|
296 | File,
|
---|
297 | Group,
|
---|
298 | Module,
|
---|
299 | Page,
|
---|
300 | ExternalPage,
|
---|
301 | QmlClass
|
---|
302 | };
|
---|
303 |
|
---|
304 | FakeNode(InnerNode *parent, const QString& name, SubType subType);
|
---|
305 |
|
---|
306 | void setTitle(const QString &title) { tle = title; }
|
---|
307 | void setSubTitle(const QString &subTitle) { stle = subTitle; }
|
---|
308 | void addGroupMember(Node *node) { gr.append(node); }
|
---|
309 |
|
---|
310 | SubType subType() const { return sub; }
|
---|
311 | QString title() const { return tle; }
|
---|
312 | QString fullTitle() const;
|
---|
313 | QString subTitle() const;
|
---|
314 | const NodeList &groupMembers() const { return gr; }
|
---|
315 |
|
---|
316 | private:
|
---|
317 | SubType sub;
|
---|
318 | QString tle;
|
---|
319 | QString stle;
|
---|
320 | NodeList gr;
|
---|
321 | };
|
---|
322 |
|
---|
323 | class QmlNode : public FakeNode
|
---|
324 | {
|
---|
325 | public:
|
---|
326 | QmlNode(InnerNode *parent, const QString& name, const ClassNode* cn)
|
---|
327 | : FakeNode(parent, name, QmlClass), cnode(cn) { }
|
---|
328 |
|
---|
329 | const ClassNode* classNode() const { return cnode; }
|
---|
330 |
|
---|
331 | private:
|
---|
332 | const ClassNode* cnode;
|
---|
333 | };
|
---|
334 |
|
---|
335 | class EnumItem
|
---|
336 | {
|
---|
337 | public:
|
---|
338 | EnumItem() { }
|
---|
339 | EnumItem(const QString& name, const QString& value)
|
---|
340 | : nam(name), val(value) { }
|
---|
341 | EnumItem(const QString& name, const QString& value, const Text &txt)
|
---|
342 | : nam(name), val(value), txt(txt) { }
|
---|
343 |
|
---|
344 | const QString& name() const { return nam; }
|
---|
345 | const QString& value() const { return val; }
|
---|
346 | const Text &text() const { return txt; }
|
---|
347 |
|
---|
348 | private:
|
---|
349 | QString nam;
|
---|
350 | QString val;
|
---|
351 | Text txt;
|
---|
352 | };
|
---|
353 |
|
---|
354 | class TypedefNode;
|
---|
355 |
|
---|
356 | class EnumNode : public LeafNode
|
---|
357 | {
|
---|
358 | public:
|
---|
359 | EnumNode(InnerNode *parent, const QString& name);
|
---|
360 |
|
---|
361 | void addItem(const EnumItem& item);
|
---|
362 | void setFlagsType(TypedefNode *typedeff);
|
---|
363 | bool hasItem(const QString &name) const { return names.contains(name); }
|
---|
364 |
|
---|
365 | const QList<EnumItem>& items() const { return itms; }
|
---|
366 | Access itemAccess(const QString& name) const;
|
---|
367 | const TypedefNode *flagsType() const { return ft; }
|
---|
368 | QString itemValue(const QString &name) const;
|
---|
369 |
|
---|
370 | private:
|
---|
371 | QList<EnumItem> itms;
|
---|
372 | QSet<QString> names;
|
---|
373 | const TypedefNode *ft;
|
---|
374 | };
|
---|
375 |
|
---|
376 | class TypedefNode : public LeafNode
|
---|
377 | {
|
---|
378 | public:
|
---|
379 | TypedefNode(InnerNode *parent, const QString& name);
|
---|
380 |
|
---|
381 | const EnumNode *associatedEnum() const { return ae; }
|
---|
382 |
|
---|
383 | private:
|
---|
384 | void setAssociatedEnum(const EnumNode *enume);
|
---|
385 |
|
---|
386 | friend class EnumNode;
|
---|
387 |
|
---|
388 | const EnumNode *ae;
|
---|
389 | };
|
---|
390 |
|
---|
391 | inline void EnumNode::setFlagsType(TypedefNode *typedeff)
|
---|
392 | {
|
---|
393 | ft = typedeff;
|
---|
394 | typedeff->setAssociatedEnum(this);
|
---|
395 | }
|
---|
396 |
|
---|
397 |
|
---|
398 | class Parameter
|
---|
399 | {
|
---|
400 | public:
|
---|
401 | Parameter() {}
|
---|
402 | Parameter(const QString& leftType, const QString& rightType = "",
|
---|
403 | const QString& name = "", const QString& defaultValue = "");
|
---|
404 | Parameter(const Parameter& p);
|
---|
405 |
|
---|
406 | Parameter& operator=(const Parameter& p);
|
---|
|
---|