Exemplo n.º 1
0
void ParserEngine::parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr)
{
	char *pBuffer = new char[PARSE_BUFFER_SIZE];
	try
	{
		std::streamsize n = readBytes(istr, pBuffer, PARSE_BUFFER_SIZE);
		while (n > 0)
		{
			if (!XML_Parse(extParser, pBuffer, static_cast<int>(n), 0))
				handleError(XML_GetErrorCode(extParser));
			if (istr.good())
				n = readBytes(istr, pBuffer, PARSE_BUFFER_SIZE);
			else 
				n = 0;
		}
		if (!XML_Parse(extParser, pBuffer, 0, 1))
			handleError(XML_GetErrorCode(extParser));
	}
	catch (...)
	{
		delete [] pBuffer;
		throw;
	}
	delete [] pBuffer;
}
Exemplo n.º 2
0
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));
}
Exemplo n.º 3
0
std::streamsize ParserEngine::readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize)
{
	if (_enablePartialReads)
	{
		istr.read(pBuffer, 1);
		if (istr.gcount() == 1)
		{
			std::streamsize n = istr.readsome(pBuffer + 1, bufferSize - 1);
			return n + 1;
		}
		else return 0;
	}
	else
	{
		istr.read(pBuffer, bufferSize);
		return istr.gcount();
	}
}
Exemplo n.º 4
0
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));
}