mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-10 19:20:44 +01:00
XmlReader: more safety
This commit is contained in:
parent
9a415017c8
commit
0ae8adc013
@ -64,19 +64,22 @@ T XmlReader::getFirstValue(const std::string &nodeName, Strs... nodeNames)
|
|||||||
{
|
{
|
||||||
LATAN_ERROR(Io, "no XML file opened");
|
LATAN_ERROR(Io, "no XML file opened");
|
||||||
}
|
}
|
||||||
//std::cout << "root: " << name[i] << " ";
|
|
||||||
for (unsigned int i = 0; i < nName; ++i)
|
for (unsigned int i = 0; i < nName; ++i)
|
||||||
{
|
{
|
||||||
//std::cout << i << ": " << name[i] << " ";
|
|
||||||
node = node->FirstChildElement(name[i].c_str());
|
node = node->FirstChildElement(name[i].c_str());
|
||||||
// std::cout <<
|
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
LATAN_ERROR(Parsing, "XML node " + name[i] + " not found");
|
LATAN_ERROR(Parsing, "XML node " + name[i] + " not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (node->GetText())
|
||||||
return strTo<T>(node->GetText());
|
{
|
||||||
|
return strTo<T>(node->GetText());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return T();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
END_NAMESPACE
|
END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user