ls1mardyn / ls1-mardyn

ls1-MarDyn is a massively parallel Molecular Dynamics (MD) code for large systems. Its main target is the simulation of thermodynamics and nanofluidics. ls1-MarDyn is designed with a focus on performance and easy extensibility.
http://www.ls1-mardyn.de
Other
28 stars 15 forks source link

XML parser's getNodeValue() returns wrong number of attributes #310

Closed cniethammer closed 4 months ago

cniethammer commented 4 months ago

Describe the bug The XML parser's getNodeValue() returns the wrong number of attributes., i.e., returns 1 even if an attribute with the specified name is not present.

Here a minimal reproducer:

#include <iostream>
#include "xmlfile.h"
#include <string>

int main(int argc, char *argv[]) {

    using namespace std;

    XMLfile xmlconfig;
    xmlconfig.initstring("<test attr=\"hello\">Its me</test>");

    string attr;
    auto ret = xmlconfig.getNodeValue("test@attr", attr);
    cout << "Num attributes: " << ret << endl;

    ret = xmlconfig.getNodeValue("test@attr_missing", attr);
    cout << "Num missing attributes: " << ret << endl;

    return 0;
}

./reproducer Num attributes: 1 Num missing attributes: 1