[Expat-discuss] Expat and C++ ?

Jez Higgins jez at jezuk.co.uk
Wed Jul 5 11:40:44 CEST 2006


hymedia wrote:
> The real problem is the C function calls... honestly... have waist enough
> time wraping Expat from c to c++ and it turns out to be realy ugly... I ll
> write my own c++ parser... thx anyways
> 

The callback functions need to be static and declared as extern "C", in
order to have the correct linkage.  Getting those to forward on to
member functions is pretty straightforward - pass the this pointer to
the Expat parser as userData, and you can then use it to forward the
call.  It took me about a morning's work from a standing start.  It's
not super-pretty, but there's no way to make it any prettier and I'll
take pragmatic over pretty any day.

My Arabica package - http://www.jezuk.co.uk/arabica - provides SAX, DOM
and XPath layered onto Expat, libxml2, Xerces or MSXML.  If it doesn't
do what you want, the Expat wrapper should give you a pretty clear steer
on what you need - look at saxexpat.h and saxexpat.cpp.

Jez

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://mail.libexpat.org/pipermail/expat-discuss/attachments/20060705/963f116e/attachment.pgp 


More information about the Expat-discuss mailing list