1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
46 #ifndef CPPCODEPARSER_H
47 #define CPPCODEPARSER_H
51 #include "codeparser.h"
58 class CppCodeParserPrivate
;
63 class CppCodeParser
: public CodeParser
69 virtual void initializeParser(const Config
& config
);
70 virtual void terminateParser();
71 virtual QString
language();
72 virtual QString
headerFileNameFilter();
73 virtual QString
sourceFileNameFilter();
74 virtual void parseHeaderFile(const Location
& location
,
75 const QString
& filePath
,
77 virtual void parseSourceFile(const Location
& location
,
78 const QString
& filePath
,
80 virtual void doneParsingHeaderFiles(Tree
*tree
);
81 virtual void doneParsingSourceFiles(Tree
*tree
);
83 const FunctionNode
*findFunctionNode(const QString
& synopsis
,
89 virtual QSet
<QString
> topicCommands();
90 virtual Node
*processTopicCommand(const Doc
& doc
,
91 const QString
& command
,
94 // might need to implement this in QsCodeParser as well.
95 virtual Node
*processTopicCommandGroup(const Doc
& doc
,
96 const QString
& command
,
97 const QStringList
& args
);
98 bool splitQmlPropertyArg(const Doc
& doc
,
103 bool splitQmlMethodArg(const Doc
& doc
,
108 virtual QSet
<QString
> otherMetaCommands();
109 virtual void processOtherMetaCommand(const Doc
& doc
,
110 const QString
& command
,
113 void processOtherMetaCommands(const Doc
& doc
, Node
*node
);
116 void reset(Tree
*tree
);
118 const Location
& location();
119 QString
previousLexeme();
121 bool match(int target
);
123 bool matchTemplateAngles(CodeChunk
*type
= 0);
124 bool matchTemplateHeader();
125 bool matchDataType(CodeChunk
*type
, QString
*var
= 0);
126 bool matchParameter(FunctionNode
*func
);
127 bool matchFunctionDecl(InnerNode
*parent
,
128 QStringList
*parentPathPtr
= 0,
129 FunctionNode
**funcPtr
= 0,
130 const QString
&templateStuff
= QString(),
131 Node::Type type
= Node::Function
,
132 bool attached
= false);
133 bool matchBaseSpecifier(ClassNode
*classe
, bool isClass
);
134 bool matchBaseList(ClassNode
*classe
, bool isClass
);
135 bool matchClassDecl(InnerNode
*parent
,
136 const QString
&templateStuff
= QString());
137 bool matchNamespaceDecl(InnerNode
*parent
);
138 bool matchUsingDecl();
139 bool matchEnumItem(InnerNode
*parent
, EnumNode
*enume
);
140 bool matchEnumDecl(InnerNode
*parent
);
141 bool matchTypedefDecl(InnerNode
*parent
);
142 bool matchProperty(InnerNode
*parent
);
143 bool matchDeclList(InnerNode
*parent
);
144 bool matchDocsAndStuff();
145 bool makeFunctionNode(const QString
&synopsis
,
146 QStringList
*parentPathPtr
,
147 FunctionNode
**funcPtr
,
149 Node::Type type
= Node::Function
,
150 bool attached
= false);
151 FunctionNode
* makeFunctionNode(const Doc
& doc
,
157 void parseQiteratorDotH(const Location
&location
, const QString
&filePath
);
158 void instantiateIteratorMacro(const QString
&container
,
159 const QString
&includeFile
,
160 const QString
¯oDef
,
162 void createExampleFileNodes(FakeNode
*fake
);
164 QMap
<QString
, Node::Type
> nodeTypeMap
;
166 Tokenizer
*tokenizer
;
169 FunctionNode::Metaness metaness
;
171 QStringList lastPath
;
175 QString sequentialIteratorDefinition
;
176 QString mutableSequentialIteratorDefinition
;
177 QString associativeIteratorDefinition
;
178 QString mutableAssociativeIteratorDefinition
;
179 QSet
<QString
> usedNamespaces
;
180 QMap
<QString
, QString
> sequentialIteratorClasses
;
181 QMap
<QString
, QString
> mutableSequentialIteratorClasses
;
182 QMap
<QString
, QString
> associativeIteratorClasses
;
183 QMap
<QString
, QString
> mutableAssociativeIteratorClasses
;
185 static QStringList exampleFiles
;
186 static QStringList exampleDirs
;
187 QString exampleNameFilter
;
188 QString exampleImageFilter
;