X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fxml%2Feasyxml.cxx;h=65a35513201a2de40a24b11b9b7cb01a63d28593;hb=b9a34b1b05ce9cab1b4b67816d7d24bd2bc364b7;hp=3636fa9d3fe46feef6eda5ac48fdc59674d9983d;hpb=090f79b951f563c406de3cb597f0c47c40756043;p=simgear.git diff --git a/simgear/xml/easyxml.cxx b/simgear/xml/easyxml.cxx index 3636fa9d..65a35513 100644 --- a/simgear/xml/easyxml.cxx +++ b/simgear/xml/easyxml.cxx @@ -1,4 +1,8 @@ -// easyxml.cxx - implementation of EasyXML interfaces. +/** + * \file easyxml.cxx - implementation of EasyXML interfaces. + * Written by David Megginson, 2000-2001 + * This file is in the Public Domain, and comes with NO WARRANTY of any kind. + */ #include @@ -7,10 +11,10 @@ #include "easyxml.hxx" #include "xmlparse.h" -#include STL_FSTREAM -#include STL_IOSTREAM +#include +#include -SG_USING_STD(ifstream); +using std::ifstream; @@ -220,37 +224,41 @@ readXML (istream &input, XMLVisitor &visitor, const string &path) // FIXME: get proper error string from system if (!input.good()) { - XML_ParserFree(parser); - throw sg_io_exception("Problem reading file", + sg_io_exception ex ("Problem reading file", sg_location(path, XML_GetCurrentLineNumber(parser), XML_GetCurrentColumnNumber(parser)), "SimGear XML Parser"); + XML_ParserFree(parser); + throw ex; } input.read(buf,16384); if (!XML_Parse(parser, buf, input.gcount(), false)) { - XML_ParserFree(parser); - throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)), + sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)), sg_location(path, XML_GetCurrentLineNumber(parser), XML_GetCurrentColumnNumber(parser)), "SimGear XML Parser"); + XML_ParserFree(parser); + throw ex; } } // Verify end of document. if (!XML_Parse(parser, buf, 0, true)) { - XML_ParserFree(parser); - throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)), + sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)), sg_location(path, XML_GetCurrentLineNumber(parser), XML_GetCurrentColumnNumber(parser)), "SimGear XML Parser"); + XML_ParserFree(parser); + throw ex; } XML_ParserFree(parser); + visitor.endXML(); } void @@ -260,12 +268,12 @@ readXML (const string &path, XMLVisitor &visitor) if (input.good()) { try { readXML(input, visitor, path); - } catch (sg_io_exception &e) { + } catch (sg_io_exception &) { input.close(); - throw e; - } catch (sg_throwable &t) { + throw; + } catch (sg_throwable &) { input.close(); - throw t; + throw; } } else { throw sg_io_exception("Failed to open file", sg_location(path), @@ -286,15 +294,17 @@ readXML (const char *buf, const int size, XMLVisitor &visitor) visitor.startXML(); if (!XML_Parse(parser, buf, size, false)) { - XML_ParserFree(parser); - throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)), + sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)), sg_location("In-memory XML buffer", XML_GetCurrentLineNumber(parser), XML_GetCurrentColumnNumber(parser)), "SimGear XML Parser"); + XML_ParserFree(parser); + throw ex; } XML_ParserFree(parser); + visitor.endXML(); } // end of easyxml.cxx