| 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 "comparisoncategory.h" |
| 9 | #include "docutilities.h" |
| 10 | #include "topic.h" |
| 11 | |
| 12 | #include "filesystem/fileresolver.h" |
| 13 | #include "boundaries/filesystem/resolvedfile.h" |
| 14 | |
| 15 | #include <QtCore/qmap.h> |
| 16 | #include <QtCore/qset.h> |
| 17 | #include <QtCore/qstring.h> |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class Atom; |
| 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]] QList<ArgPair> overloadList() const; |
| 71 | [[nodiscard]] inline bool hasOverloadCommand() const { return !overloadList().isEmpty(); } |
| 72 | [[nodiscard]] const QList<Atom *> &tableOfContents() const; |
| 73 | [[nodiscard]] const QList<int> &tableOfContentsLevels() const; |
| 74 | [[nodiscard]] const QList<Atom *> &keywords() const; |
| 75 | [[nodiscard]] const QList<Atom *> &targets() const; |
| 76 | [[nodiscard]] QStringMultiMap *metaTagMap() const; |
| 77 | [[nodiscard]] QMultiMap<ComparisonCategory, Text> *comparesWithMap() const; |
| 78 | void () const; |
| 79 | |
| 80 | static void initialize(FileResolver& file_resolver); |
| 81 | static void terminate(); |
| 82 | static void (Location &location, QString &str); |
| 83 | static void quoteFromFile(const Location &location, Quoter "er, |
| 84 | ResolvedFile resolved_file); |
| 85 | |
| 86 | private: |
| 87 | DocPrivate *m_priv { nullptr }; |
| 88 | static DocUtilities &m_utilities; |
| 89 | }; |
| 90 | Q_DECLARE_TYPEINFO(Doc, Q_RELOCATABLE_TYPE); |
| 91 | typedef QList<Doc> DocList; |
| 92 | |
| 93 | QT_END_NAMESPACE |
| 94 | |
| 95 | #endif |
| 96 | |