| 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 |
#include "CmdGlobals.h" |
|
20 |
#ifdef __WIN__ |
|
21 |
#pragma warning(disable:4786) |
|
22 |
#endif |
|
23 |
||
24 |
#include <xercesc/dom/DOM.hpp> |
|
25 |
#include <xercesc/framework/LocalFileFormatTarget.hpp> |
|
26 |
#include <iostream> |
|
27 |
#include <fstream> |
|
28 |
#include <vector> |
|
29 |
#include <algorithm> |
|
30 |
#include <time.h> |
|
31 |
||
32 |
#include "ReportGeneratorConstants.h" |
|
33 |
#include "CmdGlobals.h" |
|
34 |
#include "ReportIssue.h" |
|
35 |
#include "XMLModuleErrorHandler.h" |
|
36 |
#include "HAException.h" |
|
37 |
#include "Utils.h" |
|
38 |
#include "Issues.h" |
|
39 |
#include "BBCFileUtils.h" |
|
40 |
using namespace std; |
|
41 |
||
42 |
extern vector<pair<string,pair<string,string> > > HeaderInfoList; // vector<pair< headerfile name, pair<API name, API category>>> |
|
43 |
||
44 |
XERCES_CPP_NAMESPACE_USE |
|
45 |
||
46 |
||
47 |
const char* KXMLStyleSheet = "xml-stylesheet"; |
|
48 |
||
49 |
// Style sheet filename |
|
50 |
const char* KXMLXSL = "type=\"text/xsl\" href=\"BBCResults.xsl\""; |
|
51 |
// Base64 coding characters |
|
52 |
const char* KBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; |
|
53 |
||
54 |
#include "ReportGenerator.h" |
|
55 |
||
56 |
// ---------------------------------------------------------------------------- |
|
57 |
// ReportGenerator::ReportGenerator |
|
58 |
// ---------------------------------------------------------------------------- |
|
59 |
// |
|
60 |
ReportGenerator::ReportGenerator(string aOutputFile) |
|
61 |
: |
|
62 |
iOutputFile(aOutputFile), |
|
63 |
iIssueId(0), |
|
64 |
iDOMDocument(0), |
|
65 |
iDOMRoot(0) |
|
66 |
{
|
|
67 |
// START -- Support for file checksum and comments |
|
68 |
unsigned long crc; |
|
69 |
iCrcTable = new unsigned long[256]; |
|
70 |
for ( int i = 0; i <= 255 ; i++ ) |
|
71 |
{
|
|
72 |
crc = i; |
|
73 |
for ( int j = 8 ; j > 0; j-- ) |
|
74 |
{
|
|
75 |
if ( crc & 1 ) |
|
76 |
crc = ( crc >> 1 ) ^ 0xEDB88320L; |
|
77 |
else |
|
78 |
crc >>= 1; |
|
79 |
} |
|
80 |
iCrcTable[i] = crc; |
|
81 |
} |
|
82 |
// END -- Support for file checksum and comments |
|
83 |
} |
|
84 |
||
85 |
// ---------------------------------------------------------------------------- |
|
86 |
// ReportGenerator::~ReportGenerator |
|
87 |
// ---------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
ReportGenerator::~ReportGenerator() |
|
90 |
{
|
|
91 |
// START -- Support for file checksum and comments |
|
92 |
delete iCrcTable; |
|
93 |
iCrcTable = NULL; |
|
94 |
// END -- Support for file checksum and comments |
|
95 |
if( iDOMDocument ) |
|
96 |
{
|
|
97 |
iDOMDocument->release(); |
|
98 |
} |
|
99 |
for( issueMap::iterator i = iIssueMap.begin(); i != iIssueMap.end(); ++i ) |
|
100 |
{
|
|
101 |
delete i->second; |
|
102 |
i->second = 0; |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
// ---------------------------------------------------------------------------- |
|
107 |
// ReportGenerator::setXSL |
|
108 |
// ---------------------------------------------------------------------------- |
|
109 |
// |
|
110 |
void ReportGenerator::setXSL(string aXSLFilename, bool aIncludeInXML) |
|
111 |
{
|
|
112 |
iXSLFile = aXSLFilename; |
|
113 |
iEmbedXSL = aIncludeInXML; |
|
114 |
} |
|
115 |
||
116 |
// ---------------------------------------------------------------------------- |
|
117 |
// ReportGenerator::setDTD |
|
118 |
// ---------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
void ReportGenerator::setDTD(string aDTDFilename, bool aIncludeInDTD) |
|
121 |
{
|
|
122 |
iDTDFile = aDTDFilename; |
|
123 |
iEmbedDTD = aIncludeInDTD; |
|
124 |
} |
|
125 |
||
126 |
// ---------------------------------------------------------------------------- |
|
127 |
// ReportGenerator::startReport |
|
128 |
// ---------------------------------------------------------------------------- |
|
129 |
// |
|
130 |
void ReportGenerator::startReport() |
|
131 |
{
|
|
132 |
initialiseDOM(); |
|
133 |
} |
|
134 |
||
135 |
// ---------------------------------------------------------------------------- |
|
136 |
// ReportGenerator::finishReport |
|
137 |
// ---------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
void ReportGenerator::finishReport() |
|
140 |
{
|
|
141 |
DOMElement* issuelist = createIssueListNode(); |
|
142 |
iDOMRoot->appendChild(issuelist); |
|
143 |
dumpDOMToFile(); |
|
144 |
} |
|
145 |
||
146 |
// ---------------------------------------------------------------------------- |
|
147 |
// ReportGenerator::loadStringTables |
|
148 |
// ---------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
void ReportGenerator::loadStringTables(string aFilename) |
|
151 |
{
|
|
152 |
} |
|
153 |
||
154 |
// ---------------------------------------------------------------------------- |
|
155 |
// ReportGenerator::setCmdLineParms |
|
156 |
// ---------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
void ReportGenerator::setCmdLineParms(map<string, string> aParms) |
|
159 |
{
|
|
160 |
map<string, string>::iterator begin = aParms.begin(); |
|
161 |
map<string, string>::iterator end = aParms.end(); |
|
162 |
while (begin != end) |
|
163 |
{
|
|
164 |
iParams.insert(*begin); |
|
165 |
begin++; |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
// ---------------------------------------------------------------------------- |
|
170 |
// ReportGenerator::getCmdLineParm |
|
171 |
// ---------------------------------------------------------------------------- |
|
172 |
// |
|
173 |
string ReportGenerator::getCmdLineParm(string aParm) |
|
174 |
{
|
|
175 |
map<string, string>::iterator begin = iParams.find(aParm); |
|
176 |
if (begin != iParams.end()) |
|
177 |
{
|
|
178 |
return (*begin).second; |
|
179 |
} |
|
180 |
else |
|
181 |
{
|
|
182 |
return "Not specified"; |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
||
187 |
// ---------------------------------------------------------------------------- |
|
188 |
// ReportGenerator::setVersions |
|
189 |
// ---------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
void ReportGenerator::setVersions(string aBaseline, string aCurrent) |
|
192 |
{
|
|
193 |
iBaselineVersion = aBaseline; |
|
194 |
iCurrentVersion = aCurrent; |
|
195 |
} |
|
196 |
||
197 |
// ---------------------------------------------------------------------------- |
|
198 |
// ReportGenerator::addIssue |
|
199 |
// ---------------------------------------------------------------------------- |
|
200 |
// |
|
201 |
int ReportGenerator::addIssue(ReportIssue* aIssue) |
|
202 |
{
|
|
203 |
aIssue->iId = iIssueId++; |
|
204 |
||
205 |
string key = "<"; |
|
206 |
key += aIssue->HeaderFile(); |
|
207 |
key += "><"; |
|
208 |
key += aIssue->CompareFileName(); |
|
209 |
key += ">"; |
|
210 |
||
211 |
issueMapIterator it = iIssueMap.find(key); |
|
212 |
if (it != iIssueMap.end()) |
|
213 |
{
|
|
214 |
bool lineInfoNeed = true; |
|
215 |
// header entry is present in the report. append the issue to the header issue list |
|
216 |
issueVector* v = it->second; |
|
217 |
issueVector::iterator iv_it=v->begin(); |
|
218 |
bool notAnalysed = false; |
|
219 |
for (; iv_it != v->end(); ++iv_it) |
|
220 |
{
|
|
221 |
ReportIssue* issue = iv_it->second; |
|
222 |
||
223 |
TIssueIdentity id = issue->IdentityId(); |
|
224 |
TIssueType type = issue->TypeId(); |
|
225 |
} |
|
226 |
if( v->insert(pair<const ReportIssue*, ReportIssue*>(aIssue,aIssue)).second == false ) |
|
227 |
{
|
|
228 |
return -1; |
|
229 |
} |
|
230 |
} else |
|
231 |
{
|
|
232 |
// header entry is not present in the report. create an entry for the header with this issue |
|
233 |
issueVector* v = new issueVector(); |
|
234 |
v->insert(pair<const ReportIssue*, ReportIssue*>(aIssue,aIssue)); |
|
235 |
issueEntry entry(key,v); |
|
236 |
iIssueMap.insert(entry); |
|
237 |
} |
|
238 |
||
239 |
return iIssueId-1; |
|
240 |
} |
|
241 |
||
242 |
// ---------------------------------------------------------------------------- |
|
243 |
// ReportGenerator::addIssue |
|
244 |
// ---------------------------------------------------------------------------- |
|
245 |
// |
|
246 |
int ReportGenerator::addIssue(const string& aFile, |
|
247 |
const string& aFQName, const TIssueIdentity& aIdentityId, |
|
248 |
const TIssueType& aTypeId, const TBCSeverity& aBCSeverityId, |
|
249 |
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
|
250 |
int aLineNumber, const string& aIssueLoc, const string& aCompareFileName, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
251 |
const string& aCompilationError ) |
| 0 | 252 |
{
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
253 |
ReportIssue* issue; |
| 0 | 254 |
string fqName = aFQName; |
255 |
int loc = fqName.find(__FUN_MANGLED__); |
|
256 |
if(loc != -1) |
|
257 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
258 |
fqName = fqName.substr(0,loc); |
| 0 | 259 |
} |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
260 |
string::size_type dirSepInd = aIssueLoc.find_first_of("\\/");
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
261 |
string isslueloc(aIssueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
262 |
if( dirSepInd != string::npos && isslueloc.at(dirSepInd) != DIR_SEPARATOR ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
263 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
264 |
// We need to convert to proper dir-separator |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
265 |
replaceChar(isslueloc, isslueloc.at(dirSepInd), DIR_SEPARATOR); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
266 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
267 |
if(isslueloc == aCompareFileName) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
268 |
issue = new ReportIssue(0, aFile, fqName, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
269 |
aIdentityId, aTypeId, aBCSeverityId, aSCSeverityId, aIgnoreInformation, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
270 |
aLineNumber, "", aCompareFileName, aCompilationError); |
| 0 | 271 |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
272 |
else |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
273 |
issue = new ReportIssue(0, aFile, fqName, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
274 |
aIdentityId, aTypeId, aBCSeverityId, aSCSeverityId, aIgnoreInformation, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
275 |
aLineNumber, isslueloc, aCompareFileName, aCompilationError); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
276 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
277 |
/*return*/ |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
278 |
int ret = addIssue(issue); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
279 |
if( ret == -1) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
280 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
281 |
delete issue; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
282 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
283 |
return ret; |
| 0 | 284 |
} |
285 |
||
286 |
// ---------------------------------------------------------------------------- |
|
287 |
// ReportGenerator::dumpXSLToFile |
|
288 |
// ---------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
void ReportGenerator::dumpXSLToFile() |
|
291 |
{
|
|
292 |
} |
|
293 |
||
294 |
// ---------------------------------------------------------------------------- |
|
295 |
// ReportGenerator::dumpDTDToFile |
|
296 |
// ---------------------------------------------------------------------------- |
|
297 |
// |
|
298 |
void ReportGenerator::dumpDTDToFile() |
|
299 |
{
|
|
300 |
} |
|
301 |
||
302 |
// ---------------------------------------------------------------------------- |
|
303 |
// ReportGenerator::dumpDOMToFile |
|
304 |
// ---------------------------------------------------------------------------- |
|
305 |
// |
|
306 |
void ReportGenerator::dumpDOMToFile() |
|
307 |
{
|
|
308 |
XMLCh* features = _X("Core");
|
|
309 |
DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation(features); |
|
310 |
_XX(features); |
|
311 |
DOMWriter* writer = ((DOMImplementationLS*)imp)->createDOMWriter(); |
|
312 |
||
313 |
writer->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint,true); |
|
314 |
DOMErrorHandler* errorHandler = new XMLModuleErrorHandler(); |
|
315 |
// Set error handler |
|
316 |
writer->setErrorHandler(errorHandler); |
|
317 |
XMLCh* tempfilename = XMLString::transcode(iOutputFile.c_str()); |
|
318 |
XMLFormatTarget* ft = new LocalFileFormatTarget(tempfilename); |
|
319 |
writer->writeNode(ft, *iDOMDocument); |
|
320 |
XMLString::release(&tempfilename); |
|
321 |
delete ft; |
|
322 |
writer->release(); |
|
323 |
delete errorHandler; |
|
324 |
} |
|
325 |
||
326 |
// ---------------------------------------------------------------------------- |
|
327 |
// ReportGenerator::generateVersionIdNodes |
|
328 |
// ---------------------------------------------------------------------------- |
|
329 |
// |
|
330 |
void ReportGenerator::generateVersionIdNodes() |
|
331 |
{
|
|
332 |
} |
|
333 |
||
334 |
// ---------------------------------------------------------------------------- |
|
335 |
// ReportGenerator::initialiseDOM |
|
336 |
// ---------------------------------------------------------------------------- |
|
337 |
// |
|
338 |
void ReportGenerator::initialiseDOM() |
|
339 |
{
|
|
340 |
XMLCh * features = _X("Core");
|
|
341 |
DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation(features); |
|
342 |
_XX(features); |
|
343 |
if (imp != NULL) |
|
344 |
{
|
|
345 |
try |
|
346 |
{
|
|
347 |
XMLCh * repRoot = _X(NODE_REPORTROOT); |
|
348 |
DOMDocument* doc = imp->createDocument(NULL, repRoot, NULL); |
|
349 |
_XX(repRoot); |
|
350 |
if( iDOMDocument ) |
|
351 |
{
|
|
352 |
iDOMDocument->release(); |
|
353 |
iDOMDocument = 0; |
|
354 |
} |
|
355 |
iDOMDocument = doc; |
|
356 |
||
357 |
XMLCh * stylesheet = XMLString::transcode(KXMLStyleSheet); |
|
358 |
XMLCh * xsl = XMLString::transcode(KXMLXSL); |
|
359 |
||
360 |
// Style sheet is inserted to DOM document |
|
361 |
iDOMDocument->insertBefore( |
|
362 |
iDOMDocument->createProcessingInstruction( |
|
363 |
stylesheet, |
|
364 |
xsl |
|
365 |
), |
|
366 |
iDOMDocument->getDocumentElement() |
|
367 |
); |
|
368 |
XMLString::release(&stylesheet); |
|
369 |
XMLString::release(&xsl); |
|
370 |
||
371 |
iDOMRoot = iDOMDocument->getDocumentElement(); |
|
372 |
// Header node created |
|
373 |
DOMElement* header = createHeaderNode(); |
|
374 |
iDOMRoot->appendChild(header); |
|
375 |
} catch (const XMLException& /*e*/) |
|
376 |
{
|
|
377 |
throw HAException("Error initialising the DOM Document");
|
|
378 |
} |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
// ---------------------------------------------------------------------------- |
|
383 |
// ReportGenerator::uninitialiseDOM |
|
384 |
// ---------------------------------------------------------------------------- |
|
385 |
// |
|
386 |
void ReportGenerator::uninitialiseDOM() |
|
387 |
{
|
|
388 |
} |
|
389 |
||
390 |
// ---------------------------------------------------------------------------- |
|
391 |
// ReportGenerator::createOpenNode |
|
392 |
// ---------------------------------------------------------------------------- |
|
393 |
// |
|
394 |
DOMElement* ReportGenerator::createOpenNode(const char* aNodeName) |
|
395 |
{
|
|
396 |
DOMElement* ret = NULL; |
|
397 |
XMLCh* ch = XMLString::transcode(aNodeName); |
|
398 |
ret = iDOMDocument->createElement(ch); |
|
399 |
XMLString::release(&ch); |
|
400 |
return ret; |
|
401 |
} |
|
402 |
||
403 |
// ---------------------------------------------------------------------------- |
|
404 |
// ReportGenerator::createHeaderNode |
|
405 |
// ---------------------------------------------------------------------------- |
|
406 |
// |
|
407 |
DOMElement* ReportGenerator::createHeaderNode() |
|
408 |
{
|
|
409 |
DOMElement* ret = NULL; |
|
410 |
ret = createOpenNode(NODE_HEADER); |
|
411 |
vector<DOMElement*> childvec; |
|
412 |
||
413 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_BASELINEVERSION, iBaselineVersion.c_str())); |
|
414 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_CURRENTVERSION, iCurrentVersion.c_str())); |
|
415 |
childvec.push_back(createTimestampNode()); |
|
416 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_HAVERSION, HEADER_ANALYSER_VERSION)); |
|
417 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_FORMATVERSION, HEADER_ANALYSER_REPORT_VERSION)); |
|
418 |
childvec.push_back(createCmdLineNode()); |
|
419 |
||
420 |
appendChildrenToNode(ret, childvec); |
|
421 |
return ret; |
|
422 |
} |
|
423 |
||
424 |
// ---------------------------------------------------------------------------- |
|
425 |
// ReportGenerator::removeRemovedSubClasses |
|
426 |
// ---------------------------------------------------------------------------- |
|
427 |
// |
|
428 |
void ReportGenerator::removeRemovedSubClasses() |
|
429 |
{
|
|
430 |
issueMapIterator it = iIssueMap.begin(); |
|
431 |
for (; it != iIssueMap.end();++it) |
|
432 |
{
|
|
433 |
issueVector* iv = it->second; |
|
434 |
issueVector::iterator iv_it=iv->begin(); |
|
435 |
||
436 |
for (; iv_it != iv->end(); ++iv_it) |
|
437 |
{
|
|
438 |
ReportIssue* issue = iv_it->second; |
|
439 |
||
440 |
TIssueIdentity id = issue->IdentityId(); |
|
441 |
TIssueType type = issue->TypeId(); |
|
442 |
||
443 |
//Do not process macros or other than issues type "removed" |
|
444 |
if ( EIssueTypeRemoval == type && EIssueIdentityMacro != id ) |
|
445 |
{
|
|
446 |
string fqname = issue->FQName(); |
|
447 |
fqname += "::"; |
|
448 |
||
449 |
issueVector::iterator iv_it2=iv_it; |
|
450 |
++iv_it2; |
|
451 |
||
452 |
for (; iv_it2 != iv->end(); ++iv_it2) |
|
453 |
{
|
|
454 |
ReportIssue* issue2 = iv_it2->second; |
|
455 |
string fqname2 = issue2->FQName(); |
|
456 |
||
457 |
//If the issue is inside removed class it can be removed from list |
|
458 |
if ( 0 == fqname2.compare(0, fqname.length(), fqname) ) |
|
459 |
{
|
|
460 |
issueVector::iterator iv_it3 = iv_it2; |
|
461 |
--iv_it2; |
|
462 |
iv->erase(iv_it3); |
|
463 |
} else //No more issues inside removed class so break |
|
464 |
{
|
|
465 |
break; |
|
466 |
} |
|
467 |
} |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
} |
|
472 |
} |
|
473 |
||
474 |
// ---------------------------------------------------------------------------- |
|
475 |
// ReportGenerator::functionMapping |
|
476 |
// ---------------------------------------------------------------------------- |
|
477 |
// |
|
478 |
TIssueIdentity ReportGenerator::functionMapping(const vector<TIssueIdentity> & ids) |
|
479 |
{
|
|
480 |
||
481 |
TIssueIdentity ret = EIssueIdentityExportedFunction; |
|
482 |
||
483 |
if (ids.size() == 1) |
|
484 |
{
|
|
485 |
ret = ids[0]; |
|
486 |
} |
|
487 |
else if (ids.size() == 3) |
|
488 |
{
|
|
489 |
ret = EIssueIdentityExportedVirtualInlineFunction; |
|
490 |
} |
|
491 |
else |
|
492 |
{
|
|
493 |
if ( (EIssueIdentityExportedFunction == ids[0] && EIssueIdentityVirtualFunction == ids[1]) || |
|
494 |
(EIssueIdentityExportedFunction == ids[1] && EIssueIdentityVirtualFunction == ids[0]) ) |
|
495 |
{
|
|
496 |
ret = EIssueIdentityExportedVirtualFunction; |
|
497 |
} else if ( (EIssueIdentityExportedFunction == ids[0] && EIssueIdentityInlineFunction == ids[1]) || |
|
498 |
(EIssueIdentityExportedFunction == ids[1] && EIssueIdentityInlineFunction == ids[0]) ) |
|
499 |
{
|
|
500 |
ret = EIssueIdentityExportedInlineFunction; |
|
501 |
} else if ( (EIssueIdentityInlineFunction == ids[0] && EIssueIdentityVirtualFunction == ids[1]) || |
|
502 |
(EIssueIdentityInlineFunction == ids[1] && EIssueIdentityVirtualFunction == ids[0]) ) |
|
503 |
{
|
|
504 |
ret = EIssueIdentityVirtualInlineFunction; |
|
505 |
} |
|
506 |
} |
|
507 |
return ret; |
|
508 |
} |
|
509 |
||
510 |
// ---------------------------------------------------------------------------- |
|
511 |
// ReportGenerator::mergeFunctionIssues |
|
512 |
// ---------------------------------------------------------------------------- |
|
513 |
// |
|
514 |
void ReportGenerator::mergeFunctionIssues() |
|
515 |
{
|
|
516 |
issueMapIterator it = iIssueMap.begin(); |
|
517 |
for (; it != iIssueMap.end();++it) |
|
518 |
{
|
|
519 |
issueVector* iv = it->second; |
|
520 |
issueVector::iterator iv_it=iv->begin(); |
|
521 |
||
522 |
for (; iv_it != iv->end(); ++iv_it) |
|
523 |
{
|
|
524 |
ReportIssue* issue = iv_it->second; |
|
525 |
||
526 |
TIssueIdentity id = issue->IdentityId(); |
|
527 |
TIssueType type = issue->TypeId(); |
|
528 |
||
529 |
//Process functions only |
|
530 |
if ( |
|
531 |
EIssueIdentityExportedFunction == id || |
|
532 |
EIssueIdentityInlineFunction == id || |
|
533 |
EIssueIdentityVirtualFunction == id |
|
534 |
) |
|
535 |
{
|
|
536 |
vector<TIssueIdentity> identities; |
|
537 |
identities.reserve(3); |
|
538 |
string fqname = issue->FQName(); |
|
539 |
identities.push_back(issue->IdentityId()); |
|
540 |
issueVector::iterator iv_it2=iv_it; |
|
541 |
++iv_it2; |
|
542 |
||
543 |
TBCSeverity bcseverity = issue->BCSeverity(); |
|
544 |
TSCSeverity scseverity = issue->SCSeverity(); |
|
545 |
||
546 |
for (; iv_it2 != iv->end(); ++iv_it2) |
|
547 |
{
|
|
548 |
ReportIssue* issue2 = iv_it2->second; |
|
549 |
string fqname2 = issue2->FQName(); |
|
550 |
TIssueType type2 = issue2->TypeId(); |
|
551 |
||
552 |
//If the issue has same type and it is for the same function |
|
553 |
if ( (fqname2 == fqname) && (type2 == type) ) |
|
554 |
{
|
|
555 |
if ( issue2->BCSeverity() < bcseverity ) |
|
556 |
{
|
|
557 |
bcseverity = issue2->BCSeverity(); |
|
558 |
} |
|
559 |
if ( issue2->SCSeverity() < scseverity ) |
|
560 |
{
|
|
561 |
scseverity = issue2->SCSeverity(); |
|
562 |
} |
|
563 |
identities.push_back(issue2->IdentityId()); |
|
564 |
issueVector::iterator iv_it3 = iv_it2; |
|
565 |
--iv_it2; |
|
566 |
iv->erase(iv_it3); |
|
567 |
} |
|
568 |
} |
|
569 |
if (identities.size() > 0) |
|
570 |
{
|
|
571 |
issue->SetIdentityId( functionMapping(identities) ); |
|
572 |
issue->SetBCSeverity(bcseverity); |
|
573 |
issue->SetSCSeverity(scseverity); |
|
574 |
} |
|
575 |
} |
|
576 |
} |
|
577 |
||
578 |
} |
|
579 |
} |
|
580 |
||
581 |
// ---------------------------------------------------------------------------- |
|
582 |
// ReportGenerator::preprocessIssueList |
|
583 |
// ---------------------------------------------------------------------------- |
|
584 |
// |
|
585 |
void ReportGenerator::preprocessIssueList() |
|
586 |
{
|
|
587 |
removeRemovedSubClasses(); |
|
588 |
mergeFunctionIssues(); |
|
589 |
} |
|
590 |
||
591 |
||
592 |
// ---------------------------------------------------------------------------- |
|
593 |
// ReportGenerator::createIssueListNode |
|
594 |
// ---------------------------------------------------------------------------- |
|
595 |
// |
|
596 |
DOMElement* ReportGenerator::createIssueListNode() |
|
597 |
{
|
|
598 |
preprocessIssueList(); |
|
599 |
||
600 |
DOMElement* ret = NULL; |
|
601 |
bool apiFound = false; |
|
602 |
ret = createOpenNode(NODE_ISSUELIST); |
|
603 |
issueMapIterator it = iIssueMap.begin(); |
|
604 |
while (it != iIssueMap.end()) |
|
605 |
{
|
|
606 |
apiFound = false; |
|
607 |
issueVector* iv = it->second; |
|
608 |
issueVector::const_iterator iv_it = iv->begin(); |
|
609 |
||
610 |
DOMElement* headerfilenode = createOpenNode(NODE_ISSUELIST_HEADERFILE); |
|
611 |
DOMElement* filenamenode = createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_FILENAME, iv_it->second->HeaderFile().c_str()); |
|
612 |
headerfilenode->appendChild(filenamenode); |
|
613 |
||
614 |
// Append compared file here, Check from first Report issue, what was compare file name |
|
615 |
DOMElement* compareFileNameNode = createSimpleTextNode( |
|
616 |
NODE_ISSUELIST_HEADERFILE_COMPARE_FILENAME, iv_it->second->CompareFileName().c_str()); |
|
617 |
||
618 |
headerfilenode->appendChild( compareFileNameNode ); |
|
619 |
||
620 |
// START -- Support for file checksum and comments |
|
621 |
DOMElement* statusNode = createSimpleTextNode( NODE_ISSUELIST_HEADERFILE_STATUS, "" ); |
|
622 |
headerfilenode->appendChild( statusNode ); |
|
623 |
DOMElement* commentNode = createSimpleTextNode( NODE_ISSUELIST_HEADERFILE_COMMENT, "" ); |
|
624 |
headerfilenode->appendChild( commentNode ); |
|
625 |
||
626 |
// If Global header list is found with API info, then fill those in report file. |
|
627 |
for(unsigned int i = 0; i < HeaderInfoList.size(); i++ ) |
|
628 |
{
|
|
629 |
if(stricmp (HeaderInfoList.at(i).first.c_str(), iv_it->second->CompareFileName().c_str()) == 0) |
|
630 |
{
|
|
631 |
DOMElement* apiNode = createAPIAttributeNode( NODE_ISSUELIST_HEADERFILE_ISSUE_APISTRING, |
|
632 |
HeaderInfoList.at(i).second.first.c_str(), HeaderInfoList.at(i).second.second.c_str() ); |
|
633 |
headerfilenode->appendChild(apiNode); |
|
634 |
apiFound = true; |
|
635 |
} |
|
636 |
else if (stricmp( HeaderInfoList.at(i).first.c_str(), iv_it->second->HeaderFile().c_str()) == 0) |
|
637 |
{
|
|
638 |
DOMElement* apiNode = createAPIAttributeNode( NODE_ISSUELIST_HEADERFILE_ISSUE_APISTRING, |
|
639 |
HeaderInfoList.at(i).second.first.c_str(), HeaderInfoList.at(i).second.second.c_str() ); |
|
640 |
headerfilenode->appendChild(apiNode); |
|
641 |
apiFound = true; |
|
642 |
} |
|
643 |
if( apiFound == true ) |
|
644 |
break; |
|
645 |
} |
|
646 |
// Global list is present, but the header has not been found from the list, then add api info for the header as "Unknown" |
|
647 |
if( apiFound == false && HeaderInfoList.size() > 0) |
|
648 |
{
|
|
649 |
DOMElement* apiNode = createAPIAttributeNode( NODE_ISSUELIST_HEADERFILE_ISSUE_APISTRING, |
|
650 |
NODE_ISSUELIST_HEADERFILE_APIINFO_UNKNOWN, NODE_ISSUELIST_HEADERFILE_APIINFO_UNKNOWN ); |
|
651 |
headerfilenode->appendChild(apiNode); |
|
652 |
} |
|
653 |
//else no API info will be available for any header. |
|
654 |
||
655 |
char checksum[14]; |
|
656 |
if ( strlen( iv_it->second->CompareFileName().c_str() ) > 0) |
|
657 |
getFileCRC( iv_it->second->CompareFileName().c_str(), checksum ); |
|
658 |
else |
|
659 |
getFileCRC( iv_it->second->HeaderFile().c_str(), checksum ); |
|
660 |
||
661 |
// END -- Support for file checksum and comments |
|
662 |
||
663 |
//START -- Support for shortname tag |
|
664 |
string fn; |
|
665 |
string directory; |
|
666 |
list<pair<string, string> > dirs; |
|
667 |
||
668 |
//select current filename to display if it is present, else select base filename |
|
669 |
if ( strlen( iv_it->second->CompareFileName().c_str() ) > 0) |
|
670 |
{
|
|
671 |
fn = iv_it->second->CompareFileName().c_str(); |
|
672 |
dirs = BBCFileUtils::extractFilenames(getCmdLineParm("currentdir"));
|
|
673 |
} |
|
674 |
else |
|
675 |
{
|
|
676 |
fn = iv_it->second->HeaderFile().c_str(); |
|
677 |
dirs = BBCFileUtils::extractFilenames(getCmdLineParm("baselinedir"));
|
|
678 |
} |
|
679 |
||
680 |
//select appropriate baseline/current dir from the list of baseline/current dirs |
|
681 |
list<pair<string, string> >::iterator dirbegin = dirs.begin(); |
|
682 |
int p; |
|
683 |
for(; dirbegin != dirs.end(); dirbegin++) |
|
684 |
{
|
|
685 |
p = toLowerCaseWin(fn).find(toLowerCaseWin(dirbegin->first),0); |
|
686 |
if(p!= string::npos) |
|
687 |
{
|
|
688 |
directory = dirbegin->first; |
|
689 |
break; |
|
690 |
} |
|
691 |
} |
|
692 |
||
693 |
// remove baseline/current dir part of the filename |
|
694 |
string shortfilename; |
|
695 |
shortfilename.reserve(256); |
|
696 |
shortfilename = removeBase(fn,directory); |
|
697 |
||
698 |
// remove any leading directory separators from the filename |
|
699 |
shortfilename=trimLeadingDirSeparator(shortfilename); |
|
700 |
shortfilename = toLowerCaseWin(shortfilename); |
|
701 |
||
702 |
//create the shortname node |
|
703 |
DOMElement* shortNameNode = createSimpleTextNode( NODE_ISSUELIST_HEADERFILE_SHORTNAME,shortfilename.c_str() ); |
|
704 |
//END -- Support for shortname tag |
|
705 |
||
706 |
vector<string> issueids; |
|
707 |
for (; iv_it != iv->end(); ++iv_it) |
|
708 |
{
|
|
709 |
ReportIssue* issue = iv_it->second; |
|
710 |
DOMElement* issuenode = createIssueNode(*issue); |
|
711 |
headerfilenode->appendChild(issuenode); |
|
712 |
||
713 |
// START -- Support for file checksum and comments |
|
714 |
string issueid; |
|
715 |
char* text; |
|
716 |
text = _X( issuenode->getElementsByTagName( _X( "typeid" ) )->item(0)->getTextContent() ); |
|
717 |
issueid = text; |
|
718 |
_XX( text ); |
|
719 |
||
720 |
text = _X( issuenode->getElementsByTagName( _X( "identityid" ) )->item(0)->getTextContent() ); |
|
721 |
issueid += text; |
|
722 |
_XX( text ); |
|
723 |
||
724 |
text = _X( issuenode->getElementsByTagName( _X( "cause" ) )->item(0)->getTextContent() ); |
|
725 |
issueid += text; |
|
726 |
_XX( text ); |
|
727 |
||
728 |
issueids.push_back( issueid ); |
|
729 |
// END -- Support for file checksum and comments |
|
730 |
} |
|
731 |
||
732 |
ret->appendChild(headerfilenode); |
|
733 |
it++; |
|
734 |
||
735 |
// START -- Support for file checksum and comments |
|
736 |
sort( issueids.begin(), issueids.end() ); |
|
737 |
getIssuesCRC( issueids, &checksum[7] ); |
|
738 |
DOMElement* checksumNode = createSimpleTextNode( NODE_ISSUELIST_HEADERFILE_CHECKSUM, checksum ); |
|
739 |
headerfilenode->appendChild( checksumNode ); |
|
740 |
// END -- Support for file checksum and comments |
|
741 |
||
742 |
//START -- Support for shortname tag |
|
743 |
// insert the shortname node |
|
744 |
headerfilenode->appendChild( shortNameNode ); |
|
745 |
//END -- Support for shortname tag |
|
746 |
} |
|
747 |
return ret; |
|
748 |
} |
|
749 |
||
750 |
// ---------------------------------------------------------------------------- |
|
751 |
// ReportGenerator::createHeaderFileNode |
|
752 |
// ---------------------------------------------------------------------------- |
|
753 |
// |
|
754 |
DOMElement* ReportGenerator::createHeaderFileNode() |
|
755 |
{
|
|
756 |
DOMElement* ret = NULL; |
|
757 |
ret = createOpenNode(NODE_ISSUELIST_HEADERFILE); |
|
758 |
return ret; |
|
759 |
} |
|
760 |
||
761 |
// START -- Support for file checksum and comments |
|
762 |
||
763 |
// ---------------------------------------------------------------------------- |
|
764 |
// ReportGenerator::getIssuesCRC |
|
765 |
// ---------------------------------------------------------------------------- |
|
766 |
// |
|
767 |
void ReportGenerator::getIssuesCRC( const vector<string>& aIssueIdsVector, char* aCrcResult ) |
|
768 |
{
|
|
769 |
unsigned long crc = 0xFFFFFFFFL; |
|
770 |
vector<string>::const_iterator iter = aIssueIdsVector.begin(); |
|
771 |
||
772 |
for ( iter = aIssueIdsVector.begin(); iter != aIssueIdsVector.end(); iter++ ) |
|
773 |
for ( unsigned char* p = (unsigned char*) (*iter).c_str(); *p != '\0'; p++ ) |
|
774 |
crc = iCrcTable[ ( crc & 0xff ) ^ *p ] ^ ( crc >> 8 ); |
|
775 |
crc ^= 0xFFFFFFFFL; |
|
776 |
||
777 |
// The checksum is base64-encoded into 6 characters before it is returned. |
|
778 |
for ( int i = 0; i < 6; ++i ) |
|
779 |
aCrcResult[i] = KBase64[ ( crc >> ( 30 - 6 * i ) ) & 0x3f ]; |
|
780 |
aCrcResult[6] = '\0'; |
|
781 |
||
782 |
return; |
|
783 |
} |
|
784 |
// END -- Support for file checksum and comments |
|
785 |
||
786 |
// START -- Support for file checksum and comments |
|
787 |
||
788 |
// ---------------------------------------------------------------------------- |
|
789 |
// ReportGenerator::getFileCRC |
|
790 |
// ---------------------------------------------------------------------------- |
|
791 |
// |
|
792 |
void ReportGenerator::getFileCRC( const char* aFilename, char* aCrcResult ) |
|
793 |
{
|
|
794 |
unsigned long crc; |
|
795 |
unsigned long previousCrc; |
|
796 |
unsigned long length = 0; |
|
797 |
unsigned char* buffer = new unsigned char[512]; |
|
798 |
unsigned char* p; |
|
799 |
int count; |
|
800 |
filebuf file; |
|
801 |
||
802 |
// Calculate CRC for file; all sequences of whitespace and/or comments |
|
803 |
// are replaced with _one_ space. |
|
804 |
// States: |
|
805 |
// 0 : "within star comment" : starts with "/*" and ends when |
|
806 |
// the next "*/" is encountered |
|
807 |
// 1 : "within line comment" : starts with "//" and ends when |
|
808 |
// the next "/n" or "\r" is encountered |
|
809 |
// 2 : "normal mode" : "normal" text |
|
810 |
||
811 |
if ( file.open( aFilename, ios::in ) == NULL ) |
|
812 |
{
|
|
813 |
strcpy( aCrcResult, "*************"); |
|
814 |
return; |
|
815 |
} |
|
816 |
||
817 |
crc = 0xFFFFFFFFL; |
|
818 |
previousCrc = 0xFFFFFFFFL; |
|
819 |
int state = 2; |
|
820 |
char previousChar = ' '; |
|
821 |
char slashPreviousChar = ' '; |
|
822 |
||
823 |
for ( ; ; ) |
|
824 |
{
|
|
825 |
count = (int) file.sgetn( (char*) buffer, 512 ); |
|
826 |
if ( count == 0 ) |
|
827 |
{
|
|
828 |
break; |
|
829 |
} |
|
830 |
||
831 |
for ( p = buffer; count-- != 0; p++ ) |
|
832 |
{
|
|
833 |
if ( state == 0 ) |
|
834 |
{
|
|
835 |
if ( previousChar == '*' && *p == '/' ) |
|
836 |
{
|
|
837 |
state = 2; |
|
838 |
previousChar = slashPreviousChar; |
|
839 |
*p = ' '; |
|
840 |
} |
|
841 |
} |
|
842 |
else if ( state == 1 ) |
|
843 |
{
|
|
844 |
if ( *p == '\r' || *p == '\n' ) |
|
845 |
{
|
|
846 |
state = 2; |
|
847 |
previousChar = slashPreviousChar; |
|
848 |
*p = ' '; |
|
849 |
} |
|
850 |
} |
|
851 |
||
852 |
if ( state == 2 ) |
|
853 |
{
|
|
854 |
if ( *p == '/' && previousChar != '/' ) |
|
855 |
{
|
|
856 |
slashPreviousChar = previousChar; |
|
857 |
} |
|
858 |
||
859 |
if ( previousChar == '/' && *p == '*' ) |
|
860 |
{
|
|
861 |
state = 0; |
|
862 |
crc = previousCrc; // previous char should not be included in CRC |
|
863 |
--length; |
|
864 |
*p = ' '; // do not allow /*/ to be interpreted as a comment |
|
865 |
} |
|
866 |
else if ( previousChar == '/' && *p == '/' ) |
|
867 |
{
|
|
868 |
state = 1; |
|
869 |
crc = previousCrc; // previous char should not be included in CRC |
|
870 |
--length; |
|
871 |
} |
|
872 |
else {
|
|
873 |
if ( *p == '\t' || *p == '\r' || *p == '\n' ) |
|
874 |
{
|
|
875 |
*p = ' '; |
|
876 |
} |
|
877 |
if ( *p != ' ' || previousChar != ' ' ) |
|
878 |
{
|
|
879 |
previousCrc = crc; |
|
880 |
crc = iCrcTable[ ( crc & 0xff ) ^ *p ] ^ ( crc >> 8 ); |
|
881 |
++length; |
|
882 |
} |
|
883 |
} |
|
884 |
} |
|
885 |
previousChar = *p; |
|
886 |
} |
|
887 |
} |
|
888 |
crc ^= 0xFFFFFFFFL; |
|
889 |
file.close(); |
|
890 |
delete buffer; |
|
891 |
||
892 |
// The 42-bit checksum is made up of |
|
893 |
// * bits 32-41 : length of file MOD 1024 (10 bits) |
|
894 |
// * bits 0-31 : the CRC-32 value |
|
895 |
// This checksum is base64-encoded into 7 characters (42 bits / 6 bits) before it is returned. |
|
896 |
int val; |
|
897 |
length &= 0x3ff; |
|
898 |
||
899 |
for ( int i = 0; i < 7; ++i ) |
|
900 |
{
|
|
901 |
if ( i == 0 ) |
|
902 |
val = length >> 4; |
|
903 |
else if ( i == 1 ) |
|
904 |
val = ( ( length << 2 ) | ( crc >> 30 ) ) & 0x3f; |
|
905 |
else |
|
906 |
val = ( crc >> ( 30 - 6 * ( i - 1 ) ) ) & 0x3f; |
|
907 |
aCrcResult[i] = KBase64[val]; |
|
908 |
} |
|
909 |
aCrcResult[7] = '\0'; |
|
910 |
||
911 |
return; |
|
912 |
} |
|
913 |
// END -- Support for file checksum and comments |
|
914 |
||
915 |
// ---------------------------------------------------------------------------- |
|
916 |
// ReportGenerator::createTimestampNode |
|
917 |
// ---------------------------------------------------------------------------- |
|
918 |
// |
|
919 |
DOMElement* ReportGenerator::createTimestampNode() |
|
920 |
{
|
|
921 |
DOMElement* ret = NULL; |
|
922 |
int second, minute, hour, day, month, year; |
|
923 |
||
924 |
time_t ttime; |
|
925 |
time(&ttime); |
|
926 |
struct tm* time = localtime(&ttime); |
|
927 |
second = time->tm_sec; |
|
928 |
minute = time->tm_min; |
|
929 |
hour = time->tm_hour; |
|
930 |
day = time->tm_mday; |
|
931 |
month = time->tm_mon + 1; |
|
932 |
year = time->tm_year + 1900; |
|
933 |
||
934 |
ret = createOpenNode(NODE_HEADER_TIMESTAMP); |
|
935 |
vector<DOMElement*> childvec; |
|
936 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_DAY, day)); |
|
937 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_MONTH, month)); |
|
938 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_YEAR, year)); |
|
939 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_HOUR, hour)); |
|
940 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_MINUTE, minute)); |
|
941 |
childvec.push_back(createSimpleTextNode(NODE_HEADER_TIMESTAMP_SECOND, second)); |
|
942 |
||
943 |
appendChildrenToNode(ret, childvec); |
|
944 |
return ret; |
|
945 |
} |
|
946 |
||
947 |
// ---------------------------------------------------------------------------- |
|
948 |
// ReportGenerator::appendChildrenToNode |
|
949 |
// ---------------------------------------------------------------------------- |
|
950 |
// |
|
951 |
void ReportGenerator::appendChildrenToNode(DOMElement* aParent, const vector<DOMElement*>& aChildren) |
|
952 |
{
|
|
953 |
size_t count = aChildren.size(); |
|
954 |
for (unsigned int i = 0; i < count; i++) |
|
955 |
{
|
|
956 |
aParent->appendChild(aChildren.at(i)); |
|
957 |
} |
|
958 |
} |
|
959 |
||
960 |
// ---------------------------------------------------------------------------- |
|
961 |
// ReportGenerator::createSimpleTextNode |
|
962 |
// ---------------------------------------------------------------------------- |
|
963 |
// |
|
964 |
DOMElement* ReportGenerator::createSimpleTextNode(const char* aNodeName, const char* aNodeText) |
|
965 |
{
|
|
966 |
DOMElement* ret = NULL; |
|
967 |
||
968 |
XMLCh* ch = XMLString::transcode(aNodeName); |
|
969 |
XMLCh* ch2 = XMLString::transcode(aNodeText); |
|
970 |
ret = iDOMDocument->createElement(ch); |
|
971 |
DOMText* tn = iDOMDocument->createTextNode(ch2); |
|
972 |
ret->appendChild(tn); |
|
973 |
XMLString::release(&ch); |
|
974 |
XMLString::release(&ch2); |
|
975 |
return ret; |
|
976 |
} |
|
977 |
||
978 |
// ---------------------------------------------------------------------------- |
|
979 |
// ReportGenerator::createSimpleTextNode |
|
980 |
// ---------------------------------------------------------------------------- |
|
981 |
// |
|
982 |
DOMElement* ReportGenerator::createSimpleTextNode(const char* aNodeName, const XMLCh* aNodeText) |
|
983 |
{
|
|
984 |
DOMElement* ret = NULL; |
|
985 |
XMLCh* ch = XMLString::transcode(aNodeName); |
|
986 |
ret = iDOMDocument->createElement(ch); |
|
987 |
DOMText* tn = iDOMDocument->createTextNode(aNodeText); |
|
988 |
ret->appendChild(tn); |
|
989 |
XMLString::release(&ch); |
|
990 |
return ret; |
|
991 |
} |
|
992 |
||
993 |
// ---------------------------------------------------------------------------- |
|
994 |
// ReportGenerator::createSimpleTextNode |
|
995 |
// ---------------------------------------------------------------------------- |
|
996 |
// |
|
997 |
DOMElement* ReportGenerator::createSimpleTextNode(const char* aNodeName, const int aInteger) |
|
998 |
{
|
|
999 |
DOMElement* ret = NULL; |
|
1000 |
XMLCh* ch = XMLString::transcode(aNodeName); |
|
1001 |
string temp; |
|
1002 |
itoa(aInteger, temp, 10); |
|
1003 |
XMLCh* ch2 = XMLString::transcode(temp.c_str()); |
|
1004 |
ret = iDOMDocument->createElement(ch); |
|
1005 |
DOMText* tn = iDOMDocument->createTextNode(ch2); |
|
1006 |
ret->appendChild(tn); |
|
1007 |
XMLString::release(&ch); |
|
1008 |
XMLString::release(&ch2); |
|
1009 |
return ret; |
|
1010 |
} |
|
1011 |
// ---------------------------------------------------------------------------- |
|
1012 |
// ReportGenerator::createAttributeNode |
|
1013 |
// ---------------------------------------------------------------------------- |
|
1014 |
// |
|
1015 |
DOMElement* ReportGenerator::createAPIAttributeNode(const char* aNodeName, const char* aNodeAPI,const char* aNodeCategory) |
|
1016 |
{
|
|
1017 |
DOMElement* ret = NULL; |
|
1018 |
||
1019 |
XMLCh* ch = XMLString::transcode(aNodeName); |
|
1020 |
XMLCh* apivalue = XMLString::transcode(aNodeAPI); |
|
1021 |
XMLCh* apiName = XMLString::transcode(NODE_ISSUELIST_HEADERFILE_ISSUE_APINAME); |
|
1022 |
XMLCh* apicategoryvalue = XMLString::transcode(aNodeCategory); |
|
1023 |
XMLCh* apicategoryname = XMLString::transcode(NODE_ISSUELIST_HEADERFILE_ISSUE_APICATEGORY); |
|
1024 |
||
1025 |
ret = iDOMDocument->createElement(ch); |
|
1026 |
ret->setAttribute(apiName,apivalue); |
|
1027 |
ret->setAttribute(apicategoryname,apicategoryvalue); |
|
1028 |
||
1029 |
||
1030 |
XMLString::release(&ch); |
|
1031 |
XMLString::release(&apivalue); |
|
1032 |
XMLString::release(&apiName); |
|
1033 |
XMLString::release(&apicategoryvalue); |
|
1034 |
XMLString::release(&apicategoryname); |
|
1035 |
return ret; |
|
1036 |
} |
|
1037 |
||
1038 |
// ---------------------------------------------------------------------------- |
|
1039 |
// ReportGenerator::createCmdLineNode |
|
1040 |
// ---------------------------------------------------------------------------- |
|
1041 |
// |
|
1042 |
DOMElement* ReportGenerator::createCmdLineNode() |
|
1043 |
{
|
|
1044 |
DOMElement* ret = NULL; |
|
1045 |
ret = createOpenNode(NODE_HEADER_CMDLINE); |
|
1046 |
map<string, string>::iterator begin = iParams.begin(); |
|
1047 |
while (begin != iParams.end()) |
|
1048 |
{
|
|
1049 |
DOMElement* ParamNode = createParmNode((*begin).first.c_str(),(*begin).second.c_str()); |
|
1050 |
ret->appendChild(ParamNode); |
|
1051 |
begin++; |
|
1052 |
} |
|
1053 |
return ret; |
|
1054 |
} |
|
1055 |
||
1056 |
// ---------------------------------------------------------------------------- |
|
1057 |
// ReportGenerator::createParmNode |
|
1058 |
// ---------------------------------------------------------------------------- |
|
1059 |
// |
|
1060 |
DOMElement* ReportGenerator::createParmNode(const char* aKey, const char* aValue) |
|
1061 |
{
|
|
1062 |
DOMElement* ret = NULL; |
|
1063 |
||
1064 |
// value <parm> ** </parm> |
|
1065 |
ret = createOpenNode(NODE_HEADER_CMDLINE_PARM); |
|
1066 |
||
1067 |
// <pname> |
|
1068 |
ret->appendChild(createSimpleTextNode(NODE_HEADER_CMDLINE_PARM_PNAME, aKey)); |
|
1069 |
// <pvalue> |
|
1070 |
ret->appendChild(createSimpleTextNode(NODE_HEADER_CMDLINE_PARM_PVALUE, aValue)); |
|
1071 |
||
1072 |
return ret; |
|
1073 |
} |
|
1074 |
||
1075 |
// ---------------------------------------------------------------------------- |
|
1076 |
// ReportGenerator::createDocumentationUrlString |
|
1077 |
// ---------------------------------------------------------------------------- |
|
1078 |
// |
|
1079 |
string ReportGenerator::createDocumentationUrlString(string element) |
|
1080 |
{
|
|
1081 |
string ret; |
|
1082 |
if (getCmdLineParm(DOCURL) != "Not speciefied") |
|
1083 |
{
|
|
1084 |
ret = getCmdLineParm(DOCURL) + element; |
|
1085 |
} |
|
1086 |
else |
|
1087 |
{
|
|
1088 |
ret = ""; |
|
1089 |
} |
|
1090 |
return ret; |
|
1091 |
} |
|
1092 |
||
1093 |
// ---------------------------------------------------------------------------- |
|
1094 |
// ReportGenerator::createIssueNode |
|
1095 |
// ---------------------------------------------------------------------------- |
|
1096 |
// |
|
1097 |
DOMElement* ReportGenerator::createIssueNode(ReportIssue& aIssue) |
|
1098 |
{
|
|
1099 |
// IssueNode field element to report file |
|
1100 |
DOMElement* ret = NULL; |
|
1101 |
||
1102 |
// create file name here |
|
1103 |
ret = createOpenNode(NODE_ISSUELIST_HEADERFILE_ISSUE); |
|
1104 |
||
1105 |
vector<DOMElement*> childvec; |
|
1106 |
||
1107 |
// issue identifier field |
|
1108 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_ISSUEID, aIssue.Id())); |
|
1109 |
||
1110 |
// issue type identifier field |
|
1111 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_TYPEID, aIssue.TypeId())); |
|
1112 |
||
1113 |
// issue identify ( entity ) identifier field |
|
1114 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_IDENTITYID, aIssue.IdentityId())); |
|
1115 |
||
1116 |
// identity description |
|
1117 |
childvec.push_back(createSimpleTextNode( NODE_ISSUELIST_HEADERFILE_ISSUE_IDENTITYDESCRIPTION, aIssue.IdentityDescription())); |
|
1118 |
||
1119 |
// issue description field |
|
1120 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_TYPESTRING, aIssue.TypeDescription())); |
|
1121 |
||
1122 |
// issue cause description a.k.a FQName |
|
1123 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_CAUSE, aIssue.FQName().c_str())); |
|
1124 |
||
1125 |
// issue documentation finder field |
|
1126 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_DOCUMENTATION, createDocumentationUrlString(aIssue.FQName()).c_str())); |
|
1127 |
||
1128 |
// issue ignore finder field |
|
1129 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_IGNOREINFORMATION, aIssue.IgnoreInformationDescription().c_str())); |
|
1130 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1131 |
// issue location field |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1132 |
if(aIssue.IssueLocation().size() != 0) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1133 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_ISSUELOC, aIssue.IssueLocation().c_str())); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1134 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1135 |
// issue linenumber field |
| 0 | 1136 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_LINENUMBER, aIssue.LineNumber())); |
1137 |
||
1138 |
// issue extrainformation field |
|
1139 |
//childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_EXTRAINFORMATION, aIssue.ExtraInformationDescription().c_str())); |
|
1140 |
||
1141 |
// binary compatibility severity sub field for issue |
|
1142 |
DOMElement* bcseverity = createOpenNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY); |
|
1143 |
bcseverity->appendChild(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY_TYPEID, aIssue.BCSeverity())); |
|
1144 |
bcseverity->appendChild(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY_TYPESTRING, aIssue.BCSeverityDescription())); |
|
1145 |
||
1146 |
// source compatibility severity sub field for issue |
|
1147 |
DOMElement* scseverity = createOpenNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SCSEVERITY); |
|
1148 |
scseverity->appendChild(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY_TYPEID, aIssue.SCSeverity())); |
|
1149 |
scseverity->appendChild(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY_TYPESTRING, aIssue.SCSeverityDescription())); |
|
1150 |
||
1151 |
// if iisue type is compilation error, description of compilation error |
|
1152 |
if(aIssue.TypeId() == EIssueTypeCompilationError) |
|
1153 |
childvec.push_back(createSimpleTextNode(NODE_ISSUELIST_HEADERFILE_ISSUE_COMPILATION_ERROR, aIssue.CompilationError().c_str())); |
|
1154 |
||
1155 |
||
1156 |
appendChildrenToNode(ret, childvec); |
|
1157 |
ret->appendChild(bcseverity); |
|
1158 |
ret->appendChild(scseverity); |
|
1159 |
return ret; |
|
1160 |
} |
|
1161 |
||
1162 |
// ---------------------------------------------------------------------------- |
|
1163 |
// ReportGenerator::createSeverityNode |
|
1164 |
// ---------------------------------------------------------------------------- |
|
1165 |
// |
|
1166 |
//DOMElement* ReportGenerator::createSeverityNode(const int aId) |
|
1167 |
DOMElement* ReportGenerator::createSeverityNode() |
|
1168 |
{
|
|
1169 |
DOMElement* ret = NULL; |
|
1170 |
ret = createOpenNode(NODE_ISSUELIST_HEADERFILE_ISSUE_SEVERITY); |
|
1171 |
return ret; |
|
1172 |
} |
|
1173 |