|
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,
|
|
|
123 |
int aLineNumber, const string& aCompareFileName, const string& aCompilationError, bool alineNoNeeded = true);
|
|
|
124 |
private:
|
|
|
125 |
/**
|
|
|
126 |
* Preprocess issue list. Remove removed subclasses and merges similar issues
|
|
|
127 |
* of the same function
|
|
|
128 |
*/
|
|
|
129 |
void preprocessIssueList();
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* Preprocess issue list.
|
|
|
133 |
*/
|
|
|
134 |
TIssueIdentity functionMapping(const vector<TIssueIdentity> & ids);
|
|
|
135 |
|
|
|
136 |
/**
|
|
|
137 |
* Merges similar issues of the same function
|
|
|
138 |
*/
|
|
|
139 |
void mergeFunctionIssues();
|
|
|
140 |
|
|
|
141 |
/**
|
|
|
142 |
* Removes duplicates from the issue list, merges the different functions
|
|
|
143 |
*/
|
|
|
144 |
void removeRemovedSubClasses();
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
* Dump XSL data to file (not used)
|
|
|
148 |
*/
|
|
|
149 |
void dumpXSLToFile();
|
|
|
150 |
|
|
|
151 |
/**
|
|
|
152 |
* Dump DTD data to file (not used)
|
|
|
153 |
*/
|
|
|
154 |
void dumpDTDToFile();
|
|
|
155 |
|
|
|
156 |
/**
|
|
|
157 |
* Dump DOM data to file
|
|
|
158 |
*/
|
|
|
159 |
void dumpDOMToFile();
|
|
|
160 |
|
|
|
161 |
/**
|
|
|
162 |
* Genarate version id nodes
|
|
|
163 |
*/
|
|
|
164 |
void generateVersionIdNodes();
|
|
|
165 |
|
|
|
166 |
/**
|
|
|
167 |
* Initialise DOM
|
|
|
168 |
*/
|
|
|
169 |
void initialiseDOM();
|
|
|
170 |
|
|
|
171 |
/**
|
|
|
172 |
* Uninitialize DOM
|
|
|
173 |
*/
|
|
|
174 |
void uninitialiseDOM();
|
|
|
175 |
|
|
|
176 |
/**
|
|
|
177 |
* Generate issue list
|
|
|
178 |
*/
|
|
|
179 |
void generateIssueList();
|
|
|
180 |
|
|
|
181 |
/**
|
|
|
182 |
* Generate issues for header
|
|
|
183 |
*/
|
|
|
184 |
//void generateIssuesForHeader();
|
|
|
185 |
|
|
|
186 |
/**
|
|
|
187 |
* Get given commandline parameter value
|
|
|
188 |
*/
|
|
|
189 |
string getCmdLineParm(string aParm);
|
|
|
190 |
|
|
|
191 |
/**
|
|
|
192 |
* Create documentation URL string
|
|
|
193 |
*/
|
|
|
194 |
string createDocumentationUrlString(string element);
|
|
|
195 |
|
|
|
196 |
/**
|
|
|
197 |
* Create node with the given name
|
|
|
198 |
* @return aName node name
|
|
|
199 |
* @return pointer to DOMElement
|
|
|
200 |
*/
|
|
|
201 |
DOMElement* createOpenNode(const char* aName);
|
|
|
202 |
|
|
|
203 |
/**
|
|
|
204 |
* Create node to hold report header data
|
|
|
205 |
* @return pointer to DOMElement
|
|
|
206 |
*/
|
|
|
207 |
DOMElement* createHeaderNode();
|
|
|
208 |
|
|
|
209 |
/**
|
|
|
210 |
* Create node to hold list of issues found
|
|
|
211 |
* @return pointer to DOMElement
|
|
|
212 |
*/
|
|
|
213 |
DOMElement* createIssueListNode();
|
|
|
214 |
|
|
|
215 |
/**
|
|
|
216 |
* Create issue node
|
|
|
217 |
* @return pointer to DOMElement
|
|
|
218 |
*/
|
|
|
219 |
DOMElement* createIssueNode(ReportIssue* aIssue);
|
|
|
220 |
|
|
|
221 |
/**
|
|
|
222 |
* Create headerfile node
|
|
|
223 |
* @return the pointer to DOM node
|
|
|
224 |
*/
|
|
|
225 |
DOMElement* createHeaderFileNode();
|
|
|
226 |
|
|
|
227 |
/**
|
|
|
228 |
* Create time stamp node
|
|
|
229 |
* @return pointer to DOMElement
|
|
|
230 |
*/
|
|
|
231 |
DOMElement* createTimestampNode();
|
|
|
232 |
|
|
|
233 |
/**
|
|
|
234 |
* Create text node
|
|
|
235 |
* @param aNodeName name of the node
|
|
|
236 |
* @param aNodeText text of the node
|
|
|
237 |
* @return pointer to DOMElement
|
|
|
238 |
*/
|
|
|
239 |
DOMElement* createSimpleTextNode(const char* aNodeName, const char* aNodeText);
|
|
|
240 |
|
|
|
241 |
/**
|
|
|
242 |
* Create text node
|
|
|
243 |
* @param aNodeName name of the node
|
|
|
244 |
* @param aInteger converted to string
|
|
|
245 |
* @return pointer to DOMElement
|
|
|
246 |
*/
|
|
|
247 |
DOMElement* createSimpleTextNode(const char* aNodeName, const int aInteger);
|
|
|
248 |
|
|
|
249 |
/**
|
|
|
250 |
* Create text node
|
|
|
251 |
* @param aNodeName name of the node
|
|
|
252 |
* @param aNodeText text of the node
|
|
|
253 |
* @return pointer to DOMElement
|
|
|
254 |
*/
|
|
|
255 |
DOMElement* createSimpleTextNode(const char* aNodeName, const XMLCh* aNodeText);
|
|
|
256 |
|
|
|
257 |
/**
|
|
|
258 |
* Create attribute node
|
|
|
259 |
* @param aNodeName name of the node
|
|
|
260 |
* @param aNodeAPI attribute value (API name) of the node
|
|
|
261 |
* @param aNodeCategory attribute value (API category) of the node
|
|
|
262 |
* @return pointer to DOMElement
|
|
|
263 |
*/
|
|
|
264 |
DOMElement* createAPIAttributeNode(const char* aNodeName, const char* aNodeAPI,const char* aNodeCategory);
|
|
|
265 |
|
|
|
266 |
/**
|
|
|
267 |
* Create commandline node node. The node consists of commandline parameters.
|
|
|
268 |
* @return pointer to DOMElement
|
|
|
269 |
*/
|
|
|
270 |
DOMElement* createCmdLineNode();
|
|
|
271 |
|
|
|
272 |
/**
|
|
|
273 |
* Create parameter node
|
|
|
274 |
* @param aKey parameter key
|
|
|
275 |
* @param aValue parameter key value
|
|
|
276 |
* @return pointer to DOMElement
|
|
|
277 |
*/
|
|
|
278 |
DOMElement* createParmNode(const char* aKey, const char* aValue);
|
|
|
279 |
|
|
|
280 |
/**
|
|
|
281 |
* Create issue node
|
|
|
282 |
* @return pointer to DOMElement
|
|
|
283 |
*/
|
|
|
284 |
DOMElement* createIssueNode(ReportIssue& aIssue);
|
|
|
285 |
|
|
|
286 |
/**
|
|
|
287 |
* Create severity node
|
|
|
288 |
* @return pointer to DOMElement
|
|
|
289 |
*/
|
|
|
290 |
//DOMElement* createSeverityNode(const int aId);
|
|
|
291 |
DOMElement* createSeverityNode();
|
|
|
292 |
|
|
|
293 |
/**
|
|
|
294 |
* Append children to node
|
|
|
295 |
* @param aParent parent node
|
|
|
296 |
* @param aChildren children to append
|
|
|
297 |
*/
|
|
|
298 |
void appendChildrenToNode(DOMElement* aParent, const vector<DOMElement*>& aChildren);
|
|
|
299 |
|
|
|
300 |
// START -- Support for file checksum and comments
|
|
|
301 |
|
|
|
302 |
/**
|
|
|
303 |
* Calculate file CRC.
|
|
|
304 |
* @param aFilename file to calculate
|
|
|
305 |
* @param aCrcResult CRC value calculated
|
|
|
306 |
*/
|
|
|
307 |
void getFileCRC( const char* aFilename, char* aCrcResult );
|
|
|
308 |
|
|
|
309 |
/**
|
|
|
310 |
* Get issue CRC
|
|
|
311 |
* @param aIssueIdsVector vector of issue ids
|
|
|
312 |
* @param aCrcResult calculated CRC
|
|
|
313 |
*/
|
|
|
314 |
void getIssuesCRC( const vector<string>& aIssueIdsVector, char* aCrcResult );
|
|
|
315 |
// END -- Support for file checksum and comments
|
|
|
316 |
|
|
|
317 |
private:
|
|
|
318 |
//! output file
|
|
|
319 |
string iOutputFile;
|
|
|
320 |
|
|
|
321 |
//! output file
|
|
|
322 |
string iXSLFile;
|
|
|
323 |
|
|
|
324 |
//! output file
|
|
|
325 |
string iDTDFile;
|
|
|
326 |
|
|
|
327 |
//! Baseline version name
|
|
|
328 |
string iBaselineVersion;
|
|
|
329 |
|
|
|
330 |
//! //! Baseline version name
|
|
|
331 |
string iCurrentVersion;
|
|
|
332 |
|
|
|
333 |
//! Embed style sheet or not
|
|
|
334 |
bool iEmbedXSL;
|
|
|
335 |
|
|
|
336 |
//! Embed style Document Type Definition or not
|
|
|
337 |
bool iEmbedDTD;
|
|
|
338 |
|
|
|
339 |
//! The whole XML document
|
|
|
340 |
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* iDOMDocument;
|
|
|
341 |
|
|
|
342 |
//! Root node
|
|
|
343 |
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* iDOMRoot;
|
|
|
344 |
|
|
|
345 |
//! Commandline parameters to Header analyser
|
|
|
346 |
map<string,string> iParams;
|
|
|
347 |
|
|
|
348 |
// START -- Support for file checksum and comments
|
|
|
349 |
//! Table of CRC values
|
|
|
350 |
unsigned long* iCrcTable;
|
|
|
351 |
// END -- Support for file checksum and comments
|
|
|
352 |
|
|
|
353 |
// Struct to compare issue pointers
|
|
|
354 |
struct compareReportIssuePointers
|
|
|
355 |
{
|
|
|
356 |
bool operator()(const ReportIssue * s1,const ReportIssue * s2) const
|
|
|
357 |
{
|
|
|
358 |
return (*s1) < (*s2);
|
|
|
359 |
};
|
|
|
360 |
};
|
|
|
361 |
|
|
|
362 |
//!
|
|
|
363 |
typedef map<const ReportIssue*,ReportIssue*,compareReportIssuePointers> issueVector;
|
|
|
364 |
|
|
|
365 |
//! Entry to add to issue map
|
|
|
366 |
typedef pair<string, issueVector*> issueEntry;
|
|
|
367 |
|
|
|
368 |
//! Map holding issues
|
|
|
369 |
typedef map<string, issueVector*> issueMap;
|
|
|
370 |
|
|
|
371 |
//! Iterator for traversing issue map
|
|
|
372 |
typedef issueMap::iterator issueMapIterator;
|
|
|
373 |
|
|
|
374 |
//! Map holding issues
|
|
|
375 |
issueMap iIssueMap;
|
|
|
376 |
|
|
|
377 |
//! ID of the issue
|
|
|
378 |
int iIssueId;
|
|
|
379 |
};
|
|
|
380 |
#endif
|