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 DOC_H |
5 | #define DOC_H |
6 | |
7 | #include "location.h" |
8 | #include "docutilities.h" |
9 | #include "topic.h" |
10 | |
11 | #include "filesystem/fileresolver.h" |
12 | #include "boundaries/filesystem/resolvedfile.h" |
13 | |
14 | #include <QtCore/qmap.h> |
15 | #include <QtCore/qset.h> |
16 | #include <QtCore/qstring.h> |
17 | |
18 | QT_BEGIN_NAMESPACE |
19 | |
20 | class Atom; |
21 | class CodeMarker; |
22 | class DocPrivate; |
23 | class Quoter; |
24 | class Text; |
25 | |
26 | typedef std::pair<QString, QString> ArgPair; |
27 | typedef QList<ArgPair> ArgList; |
28 | typedef QMultiMap<QString, QString> QStringMultiMap; |
29 | |
30 | class Doc |
31 | { |
32 | public: |
33 | // the order is important |
34 | enum Sections { |
35 | NoSection = -1, |
36 | Section1 = 1, |
37 | Section2 = 2, |
38 | Section3 = 3, |
39 | Section4 = 4 |
40 | }; |
41 | |
42 | Doc() = default; |
43 | Doc(const Location &start_loc, const Location &end_loc, const QString &source, |
44 | const QSet<QString> &metaCommandSet, const QSet<QString> &topics); |
45 | Doc(const Doc &doc); |
46 | ~Doc(); |
47 | |
48 | Doc &operator=(const Doc &doc); |
49 | |
50 | [[nodiscard]] const Location &location() const; |
51 | [[nodiscard]] const Location &startLocation() const; |
52 | [[nodiscard]] bool isEmpty() const; |
53 | [[nodiscard]] const QString &source() const; |
54 | [[nodiscard]] const Text &body() const; |
55 | [[nodiscard]] Text briefText(bool inclusive = false) const; |
56 | [[nodiscard]] Text trimmedBriefText(const QString &className) const; |
57 | [[nodiscard]] Text legaleseText() const; |
58 | [[nodiscard]] QSet<QString> parameterNames() const; |
59 | [[nodiscard]] QStringList enumItemNames() const; |
60 | [[nodiscard]] QStringList omitEnumItemNames() const; |
61 | [[nodiscard]] QSet<QString> metaCommandsUsed() const; |
62 | [[nodiscard]] TopicList topicsUsed() const; |
63 | [[nodiscard]] ArgList metaCommandArgs(const QString &metaCommand) const; |
64 | [[nodiscard]] QList<Text> alsoList() const; |
65 | [[nodiscard]] bool hasTableOfContents() const; |
66 | [[nodiscard]] bool hasKeywords() const; |
67 | [[nodiscard]] bool hasTargets() const; |
68 | [[nodiscard]] bool isInternal() const; |
69 | [[nodiscard]] bool isMarkedReimp() const; |
70 | [[nodiscard]] const QList<Atom *> &tableOfContents() const; |
71 | [[nodiscard]] const QList<int> &tableOfContentsLevels() const; |
72 | [[nodiscard]] const QList<Atom *> &keywords() const; |
73 | [[nodiscard]] const QList<Atom *> &targets() const; |
74 | [[nodiscard]] QStringMultiMap *metaTagMap() const; |
75 | |
76 | static void initialize(FileResolver& file_resolver); |
77 | static void terminate(); |
78 | static void (Location &location, QString &str); |
79 | static CodeMarker *quoteFromFile(const Location &location, Quoter "er, |
80 | ResolvedFile resolved_file); |
81 | |
82 | private: |
83 | void detach(); |
84 | DocPrivate *m_priv { nullptr }; |
85 | static DocUtilities &m_utilities; |
86 | }; |
87 | Q_DECLARE_TYPEINFO(Doc, Q_RELOCATABLE_TYPE); |
88 | typedef QList<Doc> DocList; |
89 | |
90 | QT_END_NAMESPACE |
91 | |
92 | #endif |
93 | |