@@ -54,6 +54,9 @@ class SimpleTreeDecoder: public AbstractTreeDecoder {
5454class CovTreeDecoder : public AbstractTreeDecoder {
5555 public:
5656 virtual void readNode (Defect *def, const pt::ptree &node);
57+
58+ private:
59+ KeyEventDigger keDigger;
5760};
5861
5962struct JsonParser ::Private {
@@ -276,7 +279,34 @@ void CovTreeDecoder::readNode(
276279 // make sure the Defect structure is properly initialized
277280 (*def) = Defect ();
278281
282+ // read per-defect properties
283+ // TODO: read/propagate more properties from the Coverity JSON format
279284 def->checker = defNode.get <std::string>(" checkerName" );
285+ def->function = valueOf<std::string>(defNode, " functionDisplayName" , " " );
286+
287+ // count the events and allocate dst array
288+ const pt::ptree &evtList = defNode.get_child (" events" );
289+ def->events .resize (evtList.size ());
290+
291+ // decode events one by one
292+ unsigned idx = 0 ;
293+ pt::ptree::const_iterator it;
294+ for (it = evtList.begin (); it != evtList.end (); ++it, ++idx) {
295+ const pt::ptree &evtNode = it->second ;
296+ DefEvent &evt = def->events [idx];
297+
298+ evt.fileName = valueOf<std::string>(evtNode, " filePathname" , " " );
299+ evt.line = valueOf<int > (evtNode, " lineNumber" , 0 );
300+ // TODO: read column?
301+ evt.event = valueOf<std::string>(evtNode, " eventTag" , " " );
302+ evt.msg = valueOf<std::string>(evtNode, " eventDescription" , " " );
303+
304+ if (evtNode.get <bool >(" main" ))
305+ // this is a key event
306+ // TODO: detect and report re-definitions of key events
307+ def->keyEventIdx = idx;
308+ }
280309
281- throw pt::ptree_error (" CovTreeDecoder has not yet been implemented" );
310+ // initialize verbosity level of all events
311+ this ->keDigger .initVerbosity (def);
282312}
0 commit comments