From d033f0d2d15ddc84b446da0012b809f6cba1597f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Feb 2009 15:43:37 -0500 Subject: [PATCH] ENH: Allow cmXMLParser subclasses to report errors This tells cmXMLParser to report error messages through virtual method cmXMLParser::ReportError so that subclasses can override the default report. --- Source/cmXMLParser.cxx | 15 ++++++++++----- Source/cmXMLParser.h | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 7ef6d4429..09cc384d1 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -211,10 +211,15 @@ void cmXMLParserCharacterDataHandler(void* parser, const char* data, //---------------------------------------------------------------------------- void cmXMLParser::ReportXmlParseError() { - std::cerr << "Error parsing XML in stream at line " - << XML_GetCurrentLineNumber(static_cast(this->Parser)) - << ": " - << XML_ErrorString(XML_GetErrorCode( - static_cast(this->Parser))) << std::endl; + XML_Parser* parser = static_cast(this->Parser); + this->ReportError(XML_GetCurrentLineNumber(parser), + XML_GetCurrentColumnNumber(parser), + XML_ErrorString(XML_GetErrorCode(parser))); } +//---------------------------------------------------------------------------- +void cmXMLParser::ReportError(int line, int, const char* msg) +{ + std::cerr << "Error parsing XML in stream at line " + << line << ": " << msg << std::endl; +} diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h index 3580e8c85..68def9e5b 100644 --- a/Source/cmXMLParser.h +++ b/Source/cmXMLParser.h @@ -91,6 +91,9 @@ protected: //! Called by Parse to report an XML syntax error. virtual void ReportXmlParseError(); + /** Called by ReportXmlParseError with basic error info. */ + virtual void ReportError(int line, int column, const char* msg); + //! Utility for convenience of subclasses. Wraps isspace C library // routine. static int IsSpace(char c);