1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef QDOCINDEXFILES_H |
5 | #define QDOCINDEXFILES_H |
6 | |
7 | #include "node.h" |
8 | #include "tree.h" |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class Atom; |
13 | class FunctionNode; |
14 | class Generator; |
15 | class QDocDatabase; |
16 | class WebXMLGenerator; |
17 | class QXmlStreamReader; |
18 | class QXmlStreamWriter; |
19 | class QXmlStreamAttributes; |
20 | |
21 | // A callback interface for extending index sections |
22 | class IndexSectionWriter |
23 | { |
24 | public: |
25 | virtual ~IndexSectionWriter() = default; |
26 | virtual void append(QXmlStreamWriter &writer, Node *node) = 0; |
27 | }; |
28 | |
29 | class QDocIndexFiles |
30 | { |
31 | friend class QDocDatabase; |
32 | friend class WebXMLGenerator; // for using generateIndexSections() |
33 | |
34 | private: |
35 | static QDocIndexFiles *qdocIndexFiles(); |
36 | static void destroyQDocIndexFiles(); |
37 | |
38 | QDocIndexFiles(); |
39 | ~QDocIndexFiles(); |
40 | |
41 | void readIndexes(const QStringList &indexFiles); |
42 | void readIndexFile(const QString &path); |
43 | void readIndexSection(QXmlStreamReader &reader, Node *current, const QString &indexUrl); |
44 | void insertTarget(TargetRec::TargetType type, const QXmlStreamAttributes &attributes, |
45 | Node *node); |
46 | void resolveIndex(); |
47 | int indexForNode(Node *node); |
48 | bool adoptRelatedNode(Aggregate *adoptiveParent, int index); |
49 | |
50 | void generateIndex(const QString &fileName, const QString &url, const QString &title, |
51 | Generator *g); |
52 | void generateFunctionSection(QXmlStreamWriter &writer, FunctionNode *fn); |
53 | void generateFunctionSections(QXmlStreamWriter &writer, Aggregate *aggregate); |
54 | bool generateIndexSection(QXmlStreamWriter &writer, Node *node, |
55 | IndexSectionWriter *post = nullptr); |
56 | void generateIndexSections(QXmlStreamWriter &writer, Node *node, |
57 | IndexSectionWriter *post = nullptr); |
58 | QString appendAttributesToSignature(const FunctionNode *fn) const noexcept; |
59 | |
60 | private: |
61 | static QDocIndexFiles *s_qdocIndexFiles; |
62 | QDocDatabase *m_qdb {}; |
63 | Generator *m_gen {}; |
64 | QString m_project; |
65 | QList<std::pair<ClassNode *, QString>> m_basesList; |
66 | NodeList m_relatedNodes; |
67 | bool m_storeLocationInfo; |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif |
73 | |