| author | shrivatsa |
| Mon, 27 Sep 2010 14:51:17 +0530 | |
| changeset 12 | a0eee409ff14 |
| parent 3 | ebe3f8f03b59 |
| 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 __REPORT_GENERATOR_H__ |
|
20 |
#define __REPORT_GENERATOR_H__ |
|
21 |
||
22 |
#include "CmdGlobals.h" |
|
23 |
||
24 |
#include <string> |
|
25 |
#include <map> |
|
26 |
#include <vector> |
|
27 |
||
28 |
#include "ReportIssue.h" |
|
29 |
||
30 |
using namespace std; |
|
31 |
||
32 |
XERCES_CPP_NAMESPACE_USE |
|
33 |
||
34 |
/** |
|
35 |
* The ReportGenerator defines an issue reporting interface for the analysis |
|
36 |
* to use. It defines issue type IDs and issue severities and constructs |
|
37 |
* the XML document based on the reported issues. The ReportGenerator also |
|
38 |
* implements the saving of the resulting XML document to the file system. |
|
39 |
*/ |
|
40 |
class ReportGenerator |
|
41 |
{
|
|
42 |
public: |
|
43 |
/** |
|
44 |
* Destructor |
|
45 |
*/ |
|
46 |
ReportGenerator(string aOutputFile=""); |
|
47 |
||
48 |
/** |
|
49 |
* Destructor |
|
50 |
*/ |
|
51 |
~ReportGenerator(); |
|
52 |
||
53 |
public: |
|
54 |
/** |
|
55 |
* Set style sheet settings |
|
56 |
* @param aXSLFilename style sheet file |
|
57 |
* @param aIncludeInXML true if to be included in XML |
|
58 |
*/ |
|
59 |
void setXSL(string aXSLFilename, bool aIncludeInXML); |
|
60 |
||
61 |
/** |
|
62 |
* Set DTD (Document Type Definition ) usage |
|
63 |
* (method not used) |
|
64 |
* @param aDTDFilename DTD filename |
|
65 |
* @param aIncludeInDTD include DTD in XML |
|
66 |
*/ |
|
67 |
void setDTD(string aDTDFilename, bool aIncludeInDTD); |
|
68 |
||
69 |
/** |
|
70 |
* Start reporting, initalize XML-parser and create DOM document |
|
71 |
*/ |
|
72 |
void startReport(); |
|
73 |
||
74 |
/** |
|
75 |
* Finish report, dump DOM to file |
|
76 |
*/ |
|
77 |
void finishReport(); |
|
78 |
||
79 |
/** |
|
80 |
* Load strin tables |
|
81 |
* @param aFilename if to be included in XML |
|
82 |
*/ |
|
83 |
void loadStringTables(string aFilename); |
|
84 |
||
85 |
/** |
|
86 |
* Set command line parameters |
|
87 |
* @param aParms map of command line parameters |
|
88 |
*/ |
|
89 |
void setCmdLineParms(map<string, string> aParms); |
|
90 |
||
91 |
/** |
|
92 |
* Set base and currentline versions |
|
93 |
* @param aBaseline baseline version |
|
94 |
* @param aCurrent current version |
|
95 |
*/ |
|
96 |
void setVersions(string aBaseline, string aCurrent); |
|
97 |
||
98 |
/** |
|
99 |
* Adds issue to report |
|
100 |
* @param aIssue issue to report |
|
101 |
* @return the issue id, -1 if the adding was not successful |
|
102 |
*/ |
|
103 |
int addIssue(ReportIssue* aIssue); |
|
104 |
||
105 |
/** |
|
106 |
* Adds issue to the report. This node is marked as the cause for the issue |
|
107 |
* @param aFile header file |
|
108 |
* @param aFQName fully qualified name of the node |
|
109 |
* @param aIdentityId identity= Class, ExportedFunction, Enumeration, etc. |
|
110 |
* @param aTypeId what was happened ( something was removed, addded, changed..) |
|
111 |
* @param aBCSeverityId how severe the issue was for binary compatibility |
|
112 |
* @param aSCSeverityId how severe the issue was for source compatibility |
|
113 |
* @param aIgnoreInformation reason to ignore |
|
114 |
* @param aLineNumber line number of the issue (0 always) |
|
115 |
* @param aCompareFileName compare file |
|
116 |
* @param aCompilationError compilation error reason |
|
117 |
* @return the issue id, -1 if the addition was not successful |
|
118 |
*/ |
|
119 |
int addIssue(const string& aFile, |
|
120 |
const string& aFQName, const TIssueIdentity& aIdentityId, |
|
121 |
const TIssueType& aTypeId, const TBCSeverity& aBCSeverityId, |
|
122 |
const TSCSeverity& aSCSeverityId, const string& aIgnoreInformation, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
123 |
int aLineNumber, const string& issueLoc,const string& aCompareFileName, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
124 |
const string& aCompilationError); |
| 0 | 125 |
private: |
126 |
/** |
|
127 |
* Preprocess issue list. Remove removed subclasses and merges similar issues |
|
128 |
* of the same function |
|
129 |
*/ |
|
130 |
void preprocessIssueList(); |
|
131 |
||
132 |
/** |
|
133 |
* Preprocess issue list. |
|
134 |
*/ |
|
135 |
TIssueIdentity functionMapping(const vector<TIssueIdentity> & ids); |
|
136 |
||
137 |
/** |
|
138 |
* Merges similar issues of the same function |
|
139 |
*/ |
|
140 |
void mergeFunctionIssues(); |
|
141 |
||
142 |
/** |
|
143 |
* Removes duplicates from the issue list, merges the different functions |
|
144 |
*/ |
|
145 |
void removeRemovedSubClasses(); |
|
146 |
||
147 |
/** |
|
148 |
* Dump XSL data to file (not used) |
|
149 |
*/ |
|
150 |
void dumpXSLToFile(); |
|
151 |
||
152 |
/** |
|
153 |
* Dump DTD data to file (not used) |
|
154 |
*/ |
|
155 |
void dumpDTDToFile(); |
|
156 |
||
157 |
/** |
|
158 |
* Dump DOM data to file |
|
159 |
*/ |
|
160 |
void dumpDOMToFile(); |
|
161 |
||
162 |
/** |
|
163 |
* Genarate version id nodes |
|
164 |
*/ |
|
165 |
void generateVersionIdNodes(); |
|
166 |
||
167 |
/** |
|
168 |
* Initialise DOM |
|
169 |
*/ |
|
170 |
void initialiseDOM(); |
|
171 |
||
172 |
/** |
|
173 |
* Uninitialize DOM |
|
174 |
*/ |
|
175 |
void uninitialiseDOM(); |
|
176 |
||
177 |
/** |
|
178 |
* Generate issue list |
|
179 |
*/ |
|
180 |
void generateIssueList(); |
|
181 |
||
182 |
/** |
|
183 |
* Generate issues for header |
|
184 |
*/ |
|
185 |
//void generateIssuesForHeader(); |
|
186 |
||
187 |
/** |
|
188 |
* Get given commandline parameter value |
|
189 |
*/ |
|
190 |
string getCmdLineParm(string aParm); |
|
191 |
||
192 |
/** |
|
193 |
* Create documentation URL string |
|
194 |
*/ |
|
195 |
string createDocumentationUrlString(string element); |
|
196 |
||
197 |
/** |
|
198 |
* Create node with the given name |
|
199 |
* @return aName node name |
|
200 |
* @return pointer to DOMElement |
|
201 |
*/ |
|
202 |
DOMElement* createOpenNode(const char* aName); |
|
203 |
||
204 |
/** |
|
205 |
* Create node to hold report header data |
|
206 |
* @return pointer to DOMElement |
|
207 |
*/ |
|
208 |
DOMElement* createHeaderNode(); |
|
209 |
||
210 |
/** |
|
211 |
* Create node to hold list of issues found |
|
212 |
* @return pointer to DOMElement |
|
213 |
*/ |
|
214 |
DOMElement* createIssueListNode(); |
|
215 |
||
216 |
/** |
|
217 |
* Create issue node |
|
218 |
* @return pointer to DOMElement |
|
219 |
*/ |
|
220 |
DOMElement* createIssueNode(ReportIssue* aIssue); |
|
221 |
||
222 |
/** |
|
223 |
* Create headerfile node |
|
224 |
* @return the pointer to DOM node |
|
225 |
*/ |
|
226 |
DOMElement* createHeaderFileNode(); |
|
227 |
||
228 |
/** |
|
229 |
* Create time stamp node |
|
230 |
* @return pointer to DOMElement |
|
231 |
*/ |
|
232 |
DOMElement* createTimestampNode(); |
|
233 |
||
234 |
/** |
|
235 |
* Create text node |
|
236 |
* @param aNodeName name of the node |
|
237 |
* @param aNodeText text of the node |
|
238 |
* @return pointer to DOMElement |
|
239 |
*/ |
|
240 |
DOMElement* createSimpleTextNode(const char* aNodeName, const char* aNodeText); |
|
241 |
||
242 |
/** |
|
243 |
* Create text node |
|
244 |
* @param aNodeName name of the node |
|
245 |
* @param aInteger converted to string |
|
246 |
* @return pointer to DOMElement |
|
247 |
*/ |
|
248 |
DOMElement* createSimpleTextNode(const char* aNodeName, const int aInteger); |
|
249 |
||
250 |
/** |
|
251 |
* Create text node |
|
252 |
* @param aNodeName name of the node |
|
253 |
* @param aNodeText text of the node |
|
254 |
* @return pointer to DOMElement |
|
255 |
*/ |
|
256 |
DOMElement* createSimpleTextNode(const char* aNodeName, const XMLCh* aNodeText); |
|
257 |
||
258 |
/** |
|
259 |
* Create attribute node |
|
260 |
* @param aNodeName name of the node |
|
261 |
* @param aNodeAPI attribute value (API name) of the node |
|
262 |
* @param aNodeCategory attribute value (API category) of the node |
|
263 |
* @return pointer to DOMElement |
|
264 |
*/ |
|
265 |
DOMElement* createAPIAttributeNode(const char* aNodeName, const char* aNodeAPI,const char* aNodeCategory); |
|
266 |
||
267 |
/** |
|
268 |
* Create commandline node node. The node consists of commandline parameters. |
|
269 |
* @return pointer to DOMElement |
|
270 |
*/ |
|
271 |
DOMElement* createCmdLineNode(); |
|
272 |
||
273 |
/** |
|
274 |
* Create parameter node |
|
275 |
* @param aKey parameter key |
|
276 |
* @param aValue parameter key value |
|
277 |
* @return pointer to DOMElement |
|
278 |
*/ |
|
279 |
DOMElement* createParmNode(const char* aKey, const char* aValue); |
|
280 |
||
281 |
/** |
|
282 |
* Create issue node |
|
283 |
* @return pointer to DOMElement |
|
284 |
*/ |
|
285 |
DOMElement* createIssueNode(ReportIssue& aIssue); |
|
286 |
||
287 |
/** |
|
288 |
* Create severity node |
|
289 |
* @return pointer to DOMElement |
|
290 |
*/ |
|
291 |
//DOMElement* createSeverityNode(const int aId); |
|
292 |
DOMElement* createSeverityNode(); |
|
293 |
||
294 |
/** |
|
295 |
* Append children to node |
|
296 |
* @param aParent parent node |
|
297 |
* @param aChildren children to append |
|
298 |
*/ |
|
299 |
void appendChildrenToNode(DOMElement* aParent, const vector<DOMElement*>& aChildren); |
|
300 |
||
301 |
// START -- Support for file checksum and comments |
|
302 |
||
303 |
/** |
|
304 |
* Calculate file CRC. |
|
305 |
* @param aFilename file to calculate |
|
306 |
* @param aCrcResult CRC value calculated |
|
307 |
*/ |
|
308 |
void getFileCRC( const char* aFilename, char* aCrcResult ); |
|
309 |
||
310 |
/** |
|
311 |
* Get issue CRC |
|
312 |
* @param aIssueIdsVector vector of issue ids |
|
313 |
* @param aCrcResult calculated CRC |
|
314 |
*/ |
|
315 |
void getIssuesCRC( const vector<string>& aIssueIdsVector, char* aCrcResult ); |
|
316 |
// END -- Support for file checksum and comments |
|
317 |
||
318 |
private: |
|
319 |
//! output file |
|
320 |
string iOutputFile; |
|
321 |
||
322 |
//! output file |
|
323 |
string iXSLFile; |
|
324 |
||
325 |
//! output file |
|
326 |
string iDTDFile; |
|
327 |
||
328 |
//! Baseline version name |
|
329 |
string iBaselineVersion; |
|
330 |
||
331 |
//! //! Baseline version name |
|
332 |
string iCurrentVersion; |
|
333 |
||
334 |
//! Embed style sheet or not |
|
335 |
bool iEmbedXSL; |
|
336 |
||
337 |
//! Embed style Document Type Definition or not |
|
338 |
bool iEmbedDTD; |
|
339 |
||
340 |
//! The whole XML document |
|
341 |
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* iDOMDocument; |
|
342 |
||
343 |
//! Root node |
|
344 |
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* iDOMRoot; |
|
345 |
||
346 |
//! Commandline parameters to Header analyser |
|
347 |
map<string,string> iParams; |
|
348 |
||
349 |
// START -- Support for file checksum and comments |
|
350 |
//! Table of CRC values |
|
351 |
unsigned long* iCrcTable; |
|
352 |
// END -- Support for file checksum and comments |
|
353 |
||
354 |
// Struct to compare issue pointers |
|
355 |
struct compareReportIssuePointers |
|
356 |
{
|
|
357 |
bool operator()(const ReportIssue * s1,const ReportIssue * s2) const |
|
358 |
{
|
|
359 |
return (*s1) < (*s2); |
|
360 |
}; |
|
361 |
}; |
|
362 |
||
363 |
//! |
|
364 |
typedef map<const ReportIssue*,ReportIssue*,compareReportIssuePointers> issueVector; |
|
365 |
||
366 |
//! Entry to add to issue map |
|
367 |
typedef pair<string, issueVector*> issueEntry; |
|
368 |
||
369 |
//! Map holding issues |
|
370 |
typedef map<string, issueVector*> issueMap; |
|
371 |
||
372 |
//! Iterator for traversing issue map |
|
373 |
typedef issueMap::iterator issueMapIterator; |
|
374 |
||
375 |
//! Map holding issues |
|
376 |
issueMap iIssueMap; |
|
377 |
||
378 |
//! ID of the issue |
|
379 |
int iIssueId; |
|
380 |
}; |
|
381 |
#endif |