Skip to content

Commit 03a45de

Browse files
committed
xml-parser: iterate over reports and read their kind
1 parent 110d8a5 commit 03a45de

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/xml-parser.cc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class ValgrindTreeDecoder: public AbstractTreeDecoder {
3131
virtual void readRoot(
3232
const pt::ptree **pDefList,
3333
const pt::ptree *root);
34+
35+
private:
36+
Defect defPrototype = Defect("VALGRIND_WARNING");
3437
};
3538

3639
void ValgrindTreeDecoder::readRoot(
@@ -43,11 +46,29 @@ void ValgrindTreeDecoder::readRoot(
4346

4447
bool ValgrindTreeDecoder::readNode(Defect *pDef, pt::ptree::const_iterator defIter)
4548
{
49+
static const std::string errorKey = "error";
50+
if (errorKey != defIter->first)
51+
// not a node we are interested in
52+
return false;
53+
54+
// initialize the defect structure
55+
Defect &def = *pDef;
56+
def = this->defPrototype;
57+
58+
// initialize the key event
59+
def.keyEventIdx = def.events.size();
60+
def.events.push_back(DefEvent());
61+
DefEvent &keyEvent = def.events.back();
62+
keyEvent.event = "warning";
63+
64+
// read "kind" of the report
65+
const pt::ptree &defNode = defIter->second;
66+
pt::ptree::const_assoc_iterator itKind = defNode.find("kind");
67+
if (defNode.not_found() != itKind)
68+
keyEvent.event += "[" + itKind->second.get_value<std::string>() + "]";
69+
4670
// TODO
47-
(void) pDef;
48-
(void) defIter;
49-
assert(!"implemented");
50-
return false;
71+
return true;
5172
}
5273

5374
struct XmlParser::Private {

0 commit comments

Comments
 (0)