void ParserEngine::parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr) { char *pBuffer = new char[PARSE_BUFFER_SIZE]; try { istr.read(pBuffer, PARSE_BUFFER_SIZE); int n = static_cast<int>(istr.gcount()); while (n > 0) { if (!XML_Parse(extParser, pBuffer, n, 0)) handleError(XML_GetErrorCode(extParser)); if (istr.good()) { istr.read(pBuffer, PARSE_BUFFER_SIZE); n = static_cast<int>(istr.gcount()); } else n = 0; } if (!XML_Parse(extParser, pBuffer, 0, 1)) handleError(XML_GetErrorCode(extParser)); } catch (...) { delete [] pBuffer; throw; } delete [] pBuffer; }
void ParserEngine::parseByteInputStream(XMLByteInputStream& istr) { std::streamsize n = readBytes(istr, _pBuffer, PARSE_BUFFER_SIZE); while (n > 0) { if (!XML_Parse(_parser, _pBuffer, static_cast<int>(n), 0)) handleError(XML_GetErrorCode(_parser)); if (istr.good()) n = readBytes(istr, _pBuffer, PARSE_BUFFER_SIZE); else n = 0; } if (!XML_Parse(_parser, _pBuffer, 0, 1)) handleError(XML_GetErrorCode(_parser)); }
void ParserEngine::parseByteInputStream(XMLByteInputStream& istr) { istr.read(_pBuffer, PARSE_BUFFER_SIZE); int n = static_cast<int>(istr.gcount()); while (n > 0) { if (!XML_Parse(_parser, _pBuffer, n, 0)) handleError(XML_GetErrorCode(_parser)); if (istr.good()) { istr.read(_pBuffer, PARSE_BUFFER_SIZE); n = static_cast<int>(istr.gcount()); } else n = 0; } if (!XML_Parse(_parser, _pBuffer, 0, 1)) handleError(XML_GetErrorCode(_parser)); }