| author | noe\swadi |
| Mon, 26 Apr 2010 16:28:13 +0530 | |
| changeset 3 | ebe3f8f03b59 |
| parent 0 | 638b9c697799 |
| permissions | -rw-r--r-- |
| 0 | 1 |
/* |
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef _HANODEITERATOR_H_ |
|
20 |
#define _HANODEITERATOR_H_ |
|
21 |
||
22 |
#include "CmdGlobals.h" |
|
23 |
#ifdef __WIN__ |
|
24 |
#pragma warning(disable:4786) |
|
25 |
#endif |
|
26 |
||
27 |
#include <assert.h> |
|
28 |
#include <map> |
|
29 |
#include <list> |
|
30 |
#include <xercesc/dom/DOM.hpp> |
|
31 |
||
32 |
#include "ReportGenerator.h" |
|
33 |
#include "Issues.h" |
|
34 |
#include "NodeIndex.h" |
|
35 |
||
36 |
using namespace std; |
|
37 |
||
38 |
XERCES_CPP_NAMESPACE_USE |
|
39 |
||
40 |
||
41 |
/** |
|
42 |
* The BBCAnalyser utilizes the HANodeIterator for easy access to a GCCXML |
|
43 |
* generated XML document. The HANodeIterator provides methods for an |
|
44 |
* indexed access to the XML nodes with a node ID and a fully qualified |
|
45 |
* name. The issues are also reported through the HANodeIterator |
|
46 |
*/ |
|
47 |
class HANodeIterator |
|
48 |
{
|
|
49 |
public: |
|
50 |
||
51 |
/** |
|
52 |
* Constructor |
|
53 |
* @param aRootnode root DOM node |
|
54 |
* @param aNodemap referencce to NodeIndex |
|
55 |
* @param aReport reference to ReportGenerator |
|
56 |
* @param aFilesToAnalyse list of files to analyse |
|
57 |
* @param aBaselineNode true if currently handling baseline node |
|
58 |
*/ |
|
59 |
HANodeIterator(DOMNode * aRootnode, NodeIndex & aNodemap, ReportGenerator & aReport, |
|
60 |
const list< pair<string,string> >& aFilesToAnalyse, bool aBaselineNode ); |
|
61 |
||
62 |
/** |
|
63 |
* Returns node |
|
64 |
* @return pointer to DOMNode |
|
65 |
*/ |
|
66 |
DOMNode* operator->() const; |
|
67 |
||
68 |
/** |
|
69 |
* Finds node from the XML tree by the attribute "id" |
|
70 |
* @param nodeId ID of the searchable node |
|
71 |
* @return true if the node is found |
|
72 |
*/ |
|
73 |
bool FindNodeById(const XMLCh * nodeId); |
|
74 |
||
75 |
/** |
|
76 |
* Finds node from the XML tree by the fully qualified name (C++) of it |
|
77 |
* @param nodeName name the searchable node |
|
78 |
* @return true if the node is found |
|
79 |
*/ |
|
80 |
bool FindNodeByName(pair<const XMLCh *,const XMLCh *> nodeName); |
|
81 |
||
82 |
/** |
|
83 |
* Gets the fully qualified name of this node |
|
84 |
* @return fully qualified name of the node |
|
85 |
*/ |
|
86 |
pair<const XMLCh *,const XMLCh *> GetFullyQualifiedName(); |
|
87 |
||
88 |
/** |
|
89 |
* Adds this node in the index |
|
90 |
*/ |
|
91 |
void IndexNode(); |
|
92 |
||
93 |
/** |
|
94 |
* Adds this file node to the file index |
|
95 |
* @param filetoanalyse file to be anylysed |
|
96 |
*/ |
|
97 |
void IndexFileNode(bool filetoanalyse); |
|
98 |
||
99 |
/** |
|
100 |
* Generates fully qualified name for this node and adds it to index |
|
101 |
* if parameter index is true |
|
102 |
* @param index when this is true the node is added to index |
|
103 |
*/ |
|
104 |
void NameNode(bool index = false); |
|
105 |
||
106 |
/** |
|
107 |
* Gets the attribute of this node |
|
108 |
* @param attribute attribute to get |
|
109 |
* @return attribute value or NULL |
|
110 |
*/ |
|
111 |
const XMLCh* GetAttribute(const char* attribute) const; |
|
112 |
||
113 |
/** |
|
114 |
* Gets the attribute of this node |
|
115 |
* @param attribute attribute to get |
|
116 |
* @return attribute value or NULL |
|
117 |
*/ |
|
118 |
const XMLCh* GetAttribute(const XMLCh* attribute) const; |
|
119 |
||
120 |
/** |
|
121 |
* Checks if the attribute that can have values 0 or 1 has value 1 (true) |
|
122 |
* or 0 (false). If the attribute is missing return false. |
|
123 |
* |
|
124 |
* @param attribute attribute to search for |
|
125 |
* @return true if attribute is found |
|
126 |
*/ |
|
127 |
bool CheckForBooleanAttribute(const XMLCh* attribute) const; |
|
128 |
||
129 |
/** |
|
130 |
* Checks if the attribute that can have values 0 or 1 has value 1 (true) |
|
131 |
* or 0 (false). If the attribute is missing return false. |
|
132 |
* |
|
133 |
* @param attribute attribute to search for |
|
134 |
* @return true if attribute is found |
|
135 |
*/ |
|
136 |
bool CheckForBooleanAttribute(const char* attribute) const; |
|
137 |
||
138 |
/** |
|
139 |
* Set value to this node |
|
140 |
* |
|
141 |
* @param attribute attribute to set |
|
142 |
* @param value attribute value to set |
|
143 |
*/ |
|
144 |
void SetAttribute(const char* attribute, const char* value); |
|
145 |
||
146 |
/** |
|
147 |
* Set value to this node |
|
148 |
* |
|
149 |
* @param attribute attribute to set |
|
150 |
* @param value attribute value to set |
|
151 |
*/ |
|
152 |
void SetAttribute(const XMLCh* attribute, const XMLCh* value); |
|
153 |
||
154 |
/** |
|
155 |
* Set value to this node |
|
156 |
* |
|
157 |
* @param attribute attribute to set |
|
158 |
* @param value attribute value to set |
|
159 |
*/ |
|
160 |
void SetAttribute(const char* attribute, const XMLCh* value); |
|
161 |
||
162 |
/** |
|
163 |
* Set value to this node |
|
164 |
* |
|
165 |
* @param attribute attribute to set |
|
166 |
* @param value attribute value to set |
|
167 |
*/ |
|
168 |
void SetAttribute(const XMLCh* attribute, const char* value); |
|
169 |
||
170 |
/** |
|
171 |
* Get elements by tagname |
|
172 |
* @param tag tagname |
|
173 |
* @return pointer to DOMNodeList |
|
174 |
*/ |
|
175 |
DOMNodeList* GetElementsByTagName(const char* tag) const; |
|
176 |
||
177 |
/** |
|
178 |
* Get elements by tagname |
|
179 |
* @param tag tagname |
|
180 |
* @return pointer to DOMNodeList |
|
181 |
*/ |
|
182 |
DOMNodeList* GetElementsByTagName(const XMLCh* tag) const; |
|
183 |
||
184 |
/** |
|
185 |
* Adds issue to the report. This node is marked as the cause for the issue |
|
186 |
* @param aIdentityId identity= Class, ExportedFunction, Enumeration, etc. |
|
187 |
* @param aTypeId what was happened ( something was removed, addded, changed..) |
|
188 |
* @param bcseverity how severe the issue was for binary compatibility |
|
189 |
* @param scseverity how severe the issue was for source compatibility |
|
190 |
* @param ignoreinfo reason to ignore |
|
191 |
* @param fileid ID of the file |
|
192 |
* @param name filename |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
193 |
* @param lineNumber where the issue is |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
194 |
* @param issueloc in which file the issue is |
| 0 | 195 |
*/ |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
196 |
void addIssue(TIssueIdentity aIdentityId, TIssueType aTypeId, TBCSeverity bcseverity, TSCSeverity scseverity, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
197 |
string ignoreinfo, const XMLCh* fileid, const string name, int lineNumber,const string issueloc) const; |
| 0 | 198 |
|
199 |
/** |
|
200 |
* Check if this node is in the file that is currently analysed |
|
201 |
* @return true if this node is in the file that is currently analysed |
|
202 |
*/ |
|
203 |
bool toBeAnalysed(); |
|
204 |
||
205 |
/** |
|
206 |
* Generates ignore information |
|
207 |
* @param aIdentityId see above |
|
208 |
* @param aTypeId see above |
|
209 |
* @return ignore info as string |
|
210 |
*/ |
|
211 |
string generateIgnoreInformation(const TIssueIdentity& aIdentityId, const TIssueType& aTypeId) const; |
|
212 |
||
213 |
/** |
|
214 |
* Generates ignore information |
|
215 |
* @param other reference to other HANodeIterator object |
|
216 |
* @return true if the same node type found |
|
217 |
*/ |
|
218 |
bool IsSameNodeType(const HANodeIterator& other); |
|
219 |
||
220 |
public: |
|
221 |
//! Does not own |
|
222 |
DOMNode *root; |
|
223 |
||
224 |
//! Does not own |
|
225 |
DOMNode *current; |
|
226 |
||
227 |
//! Does not own |
|
228 |
NodeIndex &iNodeIndex; |
|
229 |
||
230 |
//! Reference to ReporGenerator object (Issue report) |
|
231 |
ReportGenerator &iReport; |
|
232 |
||
233 |
//! Does not own, files that is analysed |
|
234 |
const list< pair<string,string> >& iFilesToAnalyse; |
|
235 |
||
236 |
//! Is this baseline node? |
|
237 |
bool iBaselineNode; |
|
238 |
||
239 |
private: |
|
240 |
}; |
|
241 |
||
242 |
// --------------------------------------------------------------------------------------------- |
|
243 |
// A quick fix to disable compiler warnings about CheckAccessibility |
|
244 |
||
245 |
/** |
|
246 |
* Checks if the member memberNode is visible |
|
247 |
* @param memberNode the node which accessibilty is determined |
|
248 |
* @return true if accessible |
|
249 |
*/ |
|
250 |
bool CheckAccessibility(HANodeIterator memberNode); |
|
251 |
||
252 |
/** |
|
253 |
* Checks if the member memberNode is visible and if the visibility is |
|
254 |
* through inline function |
|
255 |
* @param memberNode the node which accessibilty is determined |
|
256 |
* @param exposedByInline true if node is exposed by inline |
|
257 |
* @return true if accessible |
|
258 |
*/ |
|
259 |
bool CheckAccessibility(HANodeIterator memberNode, bool & exposedByInline); |
|
260 |
||
261 |
||
262 |
/** |
|
263 |
* Checks to see if a member with access "access" is visible from class classNode |
|
264 |
* through inline function |
|
265 |
* @param classNode the node which accessibilty is determined |
|
266 |
* @param exposedByInline true if node is exposed by inline |
|
267 |
* @param access which kind of access this node has |
|
268 |
* @return true if accessible |
|
269 |
*/ |
|
270 |
bool CheckAccessibility(HANodeIterator classNode, bool & exposedByInline, TAccess access); |
|
271 |
||
272 |
// --------------------------------------------------------------------------------------------- |
|
273 |
||
274 |
||
275 |
template<TIssueIdentity Identity,TIssueType IssueType> |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
276 |
void AddIssue(const HANodeIterator* self, const HANodeIterator& ignorenode, int lineNumber, const string& aIssueLoc, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
277 |
const XMLCh* fileid, const DataMember & data) |
| 0 | 278 |
{
|
279 |
bool exposedByInline=false; |
|
280 |
CheckAccessibility(*self,exposedByInline,data.iAccess); |
|
281 |
||
282 |
TBCSeverity sev = BCseverityAccessible<Identity,IssueType>(!exposedByInline); |
|
283 |
TSCSeverity scsev = SCseverityAccessible<Identity,IssueType>(!exposedByInline); |
|
284 |
string ign = ignoreInfo<Identity,IssueType>(*self,ignorenode); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
285 |
self->addIssue(Identity,IssueType,sev,scsev,ign,fileid, data.iName,lineNumber,aIssueLoc); |
| 0 | 286 |
} |
287 |
||
288 |
template<TIssueIdentity Identity,TIssueType IssueType> |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
289 |
void AddIssue(const HANodeIterator* self, const HANodeIterator& ignorenode, int lineNumber, const string& aIssueLoc, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
290 |
const XMLCh* fileid=NULL, const string namepostfix="") |
| 0 | 291 |
{
|
292 |
bool exposedByInline=false; |
|
293 |
CheckAccessibility(*self,exposedByInline); |
|
294 |
||
295 |
TBCSeverity sev = BCseverityAccessible<Identity,IssueType>(!exposedByInline); |
|
296 |
TSCSeverity scsev = SCseverityAccessible<Identity,IssueType>(!exposedByInline); |
|
297 |
string ign = ignoreInfo<Identity,IssueType>(*self,ignorenode); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
298 |
self->addIssue(Identity,IssueType,sev,scsev,ign,fileid, namepostfix,lineNumber,aIssueLoc); |
| 0 | 299 |
} |
300 |
||
301 |
#endif |