1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the tools applications of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 ** included in the packaging of this file. Please review the following 22 ** information to ensure the GNU General Public License requirements will 23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 ** 25 ** $QT_END_LICENSE$ 26 ** 27 ****************************************************************************/ 28 29 #ifndef CODEMARKER_H 30 #define CODEMARKER_H 31 32 #include "atom.h" 33 #include "sections.h" 34 35 QT_BEGIN_NAMESPACE 36 37 class CodeMarker 38 { 39 public: 40 CodeMarker(); 41 virtual ~CodeMarker(); 42 43 virtual void initializeMarker(); 44 virtual void terminateMarker(); recognizeCode(const QString &)45 virtual bool recognizeCode(const QString & /*code*/) { return true; } recognizeExtension(const QString &)46 virtual bool recognizeExtension(const QString & /*extension*/) { return true; } recognizeLanguage(const QString &)47 virtual bool recognizeLanguage(const QString & /*language*/) { return false; } atomType()48 virtual Atom::AtomType atomType() const { return Atom::Code; } markedUpCode(const QString & code,const Node *,const Location &)49 virtual QString markedUpCode(const QString &code, const Node * /*relative*/, 50 const Location & /*location*/) 51 { 52 return protect(code); 53 } markedUpSynopsis(const Node *,const Node *,Section::Style)54 virtual QString markedUpSynopsis(const Node * /*node*/, const Node * /*relative*/, 55 Section::Style /*style*/) 56 { 57 return QString(); 58 } markedUpQmlItem(const Node *,bool)59 virtual QString markedUpQmlItem(const Node *, bool) { return QString(); } markedUpName(const Node *)60 virtual QString markedUpName(const Node * /*node*/) { return QString(); } markedUpFullName(const Node *,const Node *)61 virtual QString markedUpFullName(const Node * /*node*/, const Node * /*relative*/) 62 { 63 return QString(); 64 } markedUpEnumValue(const QString &,const Node *)65 virtual QString markedUpEnumValue(const QString & /*enumValue*/, const Node * /*relative*/) 66 { 67 return QString(); 68 } markedUpIncludes(const QStringList &)69 virtual QString markedUpIncludes(const QStringList & /*includes*/) { return QString(); } functionBeginRegExp(const QString &)70 virtual QString functionBeginRegExp(const QString & /*funcName*/) { return QString(); } functionEndRegExp(const QString &)71 virtual QString functionEndRegExp(const QString & /*funcName*/) { return QString(); } 72 virtual QStringList macRefsForNode(Node *node); 73 74 static void initialize(); 75 static void terminate(); 76 static CodeMarker *markerForCode(const QString &code); 77 static CodeMarker *markerForFileName(const QString &fileName); 78 static CodeMarker *markerForLanguage(const QString &lang); 79 static const Node *nodeForString(const QString &string); 80 static QString stringForNode(const Node *node); 81 82 QString typified(const QString &string, bool trailingSpace = false); 83 84 protected: 85 static QString protect(const QString &string); 86 static void appendProtectedString(QString *output, const QStringRef &str); 87 QString taggedNode(const Node *node); 88 QString taggedQmlNode(const Node *node); 89 QString linkTag(const Node *node, const QString &body); 90 91 private: 92 QString macName(const Node *parent, const QString &name = QString()); 93 94 static QString defaultLang; 95 static QVector<CodeMarker *> markers; 96 }; 97 98 QT_END_NAMESPACE 99 100 #endif 101