MCPcopy Create free account
hub / github.com/Kitware/VTK / ParseXML

Method ParseXML

IO/XMLParser/vtkXMLParser.cxx:263–314  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

261
262//------------------------------------------------------------------------------
263int vtkXMLParser::ParseXML()
264{
265 // Parsing of message
266 if (this->InputString)
267 {
268 if (this->InputStringLength >= 0)
269 {
270 return this->ParseBuffer(this->InputString, this->InputStringLength);
271 }
272 else
273 {
274 return this->ParseBuffer(this->InputString);
275 }
276 }
277
278 // Make sure we have input.
279 if (!this->Stream)
280 {
281 vtkErrorMacro("Parse() called with no Stream set.");
282 return 0;
283 }
284
285 // Default stream parser just reads a block at a time.
286 istream& in = *(this->Stream);
287 constexpr int bufferSize = 4096;
288 char buffer[bufferSize];
289
290 // Read in the stream and send its contents to the XML parser. This
291 // read loop is very sensitive on certain platforms with slightly
292 // broken stream libraries (like HPUX). Normally, it is incorrect
293 // to not check the error condition on the fin.read() before using
294 // the data, but the fin.gcount() will be zero if an error occurred.
295 // Therefore, the loop should be safe everywhere.
296 while (!this->ParseError && !this->ParsingComplete() && in)
297 {
298 in.read(buffer, bufferSize);
299 if (in.gcount())
300 {
301 if (!this->ParseBuffer(buffer, in.gcount()))
302 {
303 return 0;
304 }
305 }
306 }
307
308 // Clear the fail and eof bits on the input stream so we can later
309 // seek back to read data.
310 this->Stream->clear(this->Stream->rdstate() & ~ios::eofbit);
311 this->Stream->clear(this->Stream->rdstate() & ~ios::failbit);
312
313 return 1;
314}
315
316//------------------------------------------------------------------------------
317int vtkXMLParser::ParsingComplete()

Callers 1

ParseMethod · 0.95

Calls 4

ParseBufferMethod · 0.95
ParsingCompleteMethod · 0.95
readMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected