Boost logo

Boost :

From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2005-11-04 09:52:48

Jez Higgins wrote:

>>A better API that still follows the cursor-style approach from SAX,
>>is the XMLReader. It uses a pull model instead of push, i.e. there
>>are no callbacks, but instead the application advances the reader's
>>internal cursor to the next 'token'.
>>See for a comparison to SAX.
> For some definition of better. The unpleasantness with pull APIs is the
> token - you have to interrogate it for its actual type, and then
> dispatch.

Granted. But the underlaying parser which any SAX implementation would
build on would have to do that, too. You can think of the reader as
that lower layer, and thus a push API with type-safe dispatching
can easily be built on top, if that is what you want.

Of course, the other direction is possible, too. However, logistically
it is easier to put the push layer over the pull layer, i.e. the SAX
implementation on top of the reader:
As it happens, the implementation I have in mind uses libxml2, a C
library. As such between the application calling 'parse()' and the
callbacks are two language boundaries (C++ -> C and C -> C++), so
you couldn't even throw exceptions from inside the callbacks and
catch them in the main application.

If, on the other hand, the callback dispatcher itself was written in
C++, no language boundaries would need to be crossed while unwinding
the callback stack.


Boost list run by bdawes at, gregod at, cpdaniel at, john at