Commit 53dbca3c authored by Brad King's avatar Brad King

ENH: Renamed ParseStream to ParseXML and changed organization to make it...

ENH: Renamed ParseStream to ParseXML and changed organization to make it easier to read from input other than the stream.
parent e9ed6892
......@@ -21,7 +21,7 @@
#include "expat.h"
#include <ctype.h>
vtkCxxRevisionMacro(vtkXMLParser, "1.2");
vtkCxxRevisionMacro(vtkXMLParser, "1.3");
vtkStandardNewMacro(vtkXMLParser);
//----------------------------------------------------------------------------
......@@ -29,6 +29,7 @@ vtkXMLParser::vtkXMLParser()
{
this->Stream = 0;
this->Parser = 0;
this->LegacyHack = 0;
}
//----------------------------------------------------------------------------
......@@ -54,13 +55,6 @@ void vtkXMLParser::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
int vtkXMLParser::Parse()
{
// Make sure we have input.
if(!this->Stream)
{
vtkErrorMacro("Parse() called with no Stream set.");
return 0;
}
// Create the expat XML parser.
this->Parser = XML_ParserCreate(0);
XML_SetElementHandler(this->Parser,
......@@ -70,8 +64,8 @@ int vtkXMLParser::Parse()
&vtkXMLParser::CharacterDataHandlerFunction);
XML_SetUserData(this->Parser, this);
// Parse the input stream.
int result = this->ParseStream();
// Parse the input.
int result = this->ParseXML();
if(result)
{
......@@ -90,9 +84,30 @@ int vtkXMLParser::Parse()
return result;
}
//----------------------------------------------------------------------------
int vtkXMLParser::ParseXML()
{
// Make sure we have input.
if(!this->Stream)
{
vtkErrorMacro("Parse() called with no Stream set.");
return 0;
}
this->LegacyHack = 1;
int result = this->ParseStream();
if(this->LegacyHack)
{
vtkWarningMacro("The ParseStream() method has been deprectated and "
"will soon be removed. Use ParseXML() instead.");
}
return result;
}
//----------------------------------------------------------------------------
int vtkXMLParser::ParseStream()
{
this->LegacyHack = 0;
// Default stream parser just reads a block at a time.
istream& in = *(this->Stream);
const int bufferSize = 4096;
......
......@@ -44,8 +44,8 @@ public:
//ETX
// Description:
// Parse the input stream.
int Parse();
// Parse the XML input.
virtual int Parse();
protected:
vtkXMLParser();
......@@ -58,7 +58,10 @@ protected:
void* Parser;
// Called by Parse() to read the stream and call ParseBuffer. Can
// be replaced by subclasses to change how the stream is read.
// be replaced by subclasses to change how input is read.
virtual int ParseXML();
// Legacy method. Deprecated. Use ParseXML instead.
virtual int ParseStream();
// Called before each block of input is read from the stream to
......@@ -126,6 +129,9 @@ protected:
// CharacterDataHandler.
static void CharacterDataHandlerFunction(void* parser, const char* data,
int length);
int LegacyHack;
private:
vtkXMLParser(const vtkXMLParser&); // Not implemented.
void operator=(const vtkXMLParser&); // Not implemented.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment