Commit dc933a2c authored by Andy Cedilnik's avatar Andy Cedilnik

Add support for substrings

parent 42b76a9f
......@@ -22,16 +22,17 @@
#include <ctype.h>
#include <sys/stat.h>
vtkCxxRevisionMacro(vtkXMLParser, "1.11");
vtkCxxRevisionMacro(vtkXMLParser, "1.12");
vtkStandardNewMacro(vtkXMLParser);
//----------------------------------------------------------------------------
vtkXMLParser::vtkXMLParser()
{
this->Stream = 0;
this->Parser = 0;
this->FileName = 0;
this->InputString = 0;
this->Stream = 0;
this->Parser = 0;
this->FileName = 0;
this->InputString = 0;
this->InputStringLength = 0;
}
//----------------------------------------------------------------------------
......@@ -61,11 +62,23 @@ void vtkXMLParser::PrintSelf(ostream& os, vtkIndent indent)
int vtkXMLParser::Parse(const char* inputString)
{
this->InputString = inputString;
this->InputStringLength = -1;
int result = this->vtkXMLParser::Parse();
this->InputString = 0;
return result;
}
//----------------------------------------------------------------------------
int vtkXMLParser::Parse(const char* inputString, unsigned int length)
{
this->InputString = inputString;
this->InputStringLength = length;
int result = this->vtkXMLParser::Parse();
this->InputString = 0;
this->InputStringLength = -1;
return result;
}
//----------------------------------------------------------------------------
int vtkXMLParser::Parse()
......@@ -135,7 +148,14 @@ int vtkXMLParser::ParseXML()
// Parsing of message
if ( this->InputString )
{
return this->ParseBuffer(this->InputString);
if ( this->InputStringLength >= 0 )
{
return this->ParseBuffer(this->InputString, this->InputStringLength);
}
else
{
return this->ParseBuffer(this->InputString);
}
}
// Make sure we have input.
......
......@@ -56,8 +56,10 @@ public:
virtual int Parse();
// Description:
// Parse the XML message.
// Parse the XML message. If length is specified, parse only the
// first "length" characters
virtual int Parse(const char* inputString);
virtual int Parse(const char* inputString, unsigned int length);
// Description:
// Set and get file name.
......@@ -76,6 +78,7 @@ protected:
// Character message to parse
const char* InputString;
int InputStringLength;
// Expat parser structure. Exists only during call to Parse().
void* Parser;
......
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