[Expat-discuss] isFinal parameter in XML_Parser() and XML_ParseBuffer()
Bob Lee
crazybob at crazybob.org
Mon Oct 22 21:22:02 CEST 2007
Passing isFinal isn't required, but passing true enables you to get an error
from Expat if the XML is incomplete.
Bob
On 10/22/07, Albrecht Fritzsche <ali at mental.com> wrote:
>
> Hi,
>
> I cannot find much documentation about this isFinal parameter in calls
> like XML_Parser() and XML_ParseBuffer(). Is it vital that this one was
> called or can I get away w/o using it?
>
> My parsing loop looks like
>
> const size_t BUFFSIZE = 8192;
> char buffer[BUFFSIZE];
>
> bool done = false;
> while (!done) {
> int size = m_reader->read(buffer, BUFFSIZE);
> if (size == 0) {
> // (Debug, "End of file reached"); //<--
> break;
> }
> else if (size < BUFFSIZE) {
> done = true;
> }
>
> if (XML_Parse(parser, buffer, int(size), done) == 0) {
> // (Warning, "Parse error");
> return false;
> }
> }
>
> So, if the file size is exactly equal to BUFFSIZE then the XML_Parser()
> gets called only once, the second iteration in the while loop terminates
> because the reader returns now 0.
>
> Do I have to add in line //<-- a
>
> XML_Parse(parser, buffer, 0, true);
>
> just for the sake of passing the EndOfFile indication?
>
> Thanks
> Ali
>
> _______________________________________________
> Expat-discuss mailing list
> Expat-discuss at libexpat.org
> http://mail.libexpat.org/mailman/listinfo/expat-discuss
>
More information about the Expat-discuss
mailing list