source: trunk/tools/qdoc3/codemarker.h@ 497

Last change on this file since 497 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.9 KB
Line 
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 codemarker.h
44*/
45
46#ifndef CODEMARKER_H
47#define CODEMARKER_H
48
49#include <qpair.h>
50
51#include "node.h"
52
53QT_BEGIN_NAMESPACE
54
55class Config;
56class Tree;
57
58struct Section
59{
60 QString name;
61 QString singularMember;
62 QString pluralMember;
63 NodeList members;
64 QList<QPair<ClassNode *, int> > inherited;
65
66 Section() { }
67 Section(const QString& name0,
68 const QString& singularMember0,
69 const QString& pluralMember0)
70 : name(name0),
71 singularMember(singularMember0),
72 pluralMember(pluralMember0) { }
73};
74
75struct FastSection
76{
77 const InnerNode *innerNode;
78 QString name;
79 QString singularMember;
80 QString pluralMember;
81 QMap<QString, Node *> memberMap;
82 QList<QPair<ClassNode *, int> > inherited;
83
84 FastSection(const InnerNode *innerNode0,
85 const QString& name0 = "",
86 const QString& singularMember0 = "member",
87 const QString& pluralMember0 = "members")
88 : innerNode(innerNode0),
89 name(name0),
90 singularMember(singularMember0),
91 pluralMember(pluralMember0) { }
92};
93
94class CodeMarker
95{
96 public:
97 enum SynopsisStyle { Summary, Detailed, SeparateList, Accessors };
98 enum Status { Compat, Obsolete, Okay };
99
100 CodeMarker();
101 virtual ~CodeMarker();
102
103 virtual void initializeMarker(const Config& config);
104 virtual void terminateMarker();
105 virtual bool recognizeCode(const QString& code) = 0;
106 virtual bool recognizeExtension(const QString& ext) = 0;
107 virtual bool recognizeLanguage(const QString& lang) = 0;
108 virtual QString plainName(const Node *node) = 0;
109 virtual QString plainFullName(const Node *node,
110 const Node *relative = 0) = 0;
111 virtual QString markedUpCode(const QString& code,
112 const Node *relative,
113 const QString& dirPath) = 0;
114 virtual QString markedUpSynopsis(const Node *node,
115 const Node *relative,
116 SynopsisStyle style) = 0;
117 virtual QString markedUpName(const Node *node) = 0;
118 virtual QString markedUpFullName(const Node *node,
119 const Node *relative = 0) = 0;
120 virtual QString markedUpEnumValue(const QString &enumValue,
121 const Node *relative) = 0;
122 virtual QString markedUpIncludes(const QStringList& includes) = 0;
123 virtual QString functionBeginRegExp(const QString& funcName) = 0;
124 virtual QString functionEndRegExp(const QString& funcName) = 0;
125 virtual QList<Section> sections(const InnerNode *inner,
126 SynopsisStyle style,
127 Status status) = 0;
128 virtual const Node *resolveTarget(const QString& target,
129 const Tree *tree,
130 const Node *relative) = 0;
131 virtual QStringList macRefsForNode(const Node *node);
132
133 static void initialize(const Config& config);
134 static void terminate();
135 static CodeMarker *markerForCode(const QString& code);
136 static CodeMarker *markerForFileName(const QString& fileName);
137 static CodeMarker *markerForLanguage(const QString& lang);
138 static const Node *nodeForString(const QString& string);
139 static QString stringForNode(const Node *node);
140
141 protected:
142 bool hurryUp() const { return !slow; }
143
144 virtual QString sortName(const Node *node);
145 QString protect(const QString &string);
146 QString typified(const QString &string);
147 QString taggedNode(const Node *node);
148 QString linkTag(const Node *node, const QString& body);
149 void insert(FastSection &fastSection,
150 Node *node,
151 SynopsisStyle style,
152 Status status);
153 void append(QList<Section>& sectionList, const FastSection& fastSection);
154
155 private:
156 QString macName(const Node *parent, const QString &name = QString());
157
158 bool slow;
159
160 static QString defaultLang;
161 static QList<CodeMarker *> markers;
162};
163
164QT_END_NAMESPACE
165
166#endif
Note: See TracBrowser for help on using the repository browser.