Base: [skip ci] in XMLReader class replace assert(0) calls with throwing an XMLAttributeError exception
This commit is contained in:
@@ -130,39 +130,45 @@ long Base::XMLReader::getAttributeAsInteger(const char* AttrName) const
|
||||
{
|
||||
AttrMapType::const_iterator pos = AttrMap.find(AttrName);
|
||||
|
||||
if (pos != AttrMap.end())
|
||||
if (pos != AttrMap.end()) {
|
||||
return atol(pos->second.c_str());
|
||||
else
|
||||
}
|
||||
else {
|
||||
// wrong name, use hasAttribute if not sure!
|
||||
assert(0);
|
||||
|
||||
return 0;
|
||||
std::ostringstream msg;
|
||||
msg << "XML Attribute: \"" << AttrName << "\" not found";
|
||||
throw Base::XMLAttributeError(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long Base::XMLReader::getAttributeAsUnsigned(const char* AttrName) const
|
||||
{
|
||||
AttrMapType::const_iterator pos = AttrMap.find(AttrName);
|
||||
|
||||
if (pos != AttrMap.end())
|
||||
if (pos != AttrMap.end()) {
|
||||
return strtoul(pos->second.c_str(),0,10);
|
||||
else
|
||||
}
|
||||
else {
|
||||
// wrong name, use hasAttribute if not sure!
|
||||
assert(0);
|
||||
|
||||
return 0;
|
||||
std::ostringstream msg;
|
||||
msg << "XML Attribute: \"" << AttrName << "\" not found";
|
||||
throw Base::XMLAttributeError(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
double Base::XMLReader::getAttributeAsFloat (const char* AttrName) const
|
||||
{
|
||||
AttrMapType::const_iterator pos = AttrMap.find(AttrName);
|
||||
|
||||
if (pos != AttrMap.end())
|
||||
if (pos != AttrMap.end()) {
|
||||
return atof(pos->second.c_str());
|
||||
else
|
||||
}
|
||||
else {
|
||||
// wrong name, use hasAttribute if not sure!
|
||||
assert(0);
|
||||
|
||||
return 0.0;
|
||||
std::ostringstream msg;
|
||||
msg << "XML Attribute: \"" << AttrName << "\" not found";
|
||||
throw Base::XMLAttributeError(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
const char* Base::XMLReader::getAttribute (const char* AttrName) const
|
||||
|
||||
Reference in New Issue
Block a user