Re: Expat and C++ ?
hymedia <[email protected]>
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
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 -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Albrecht Fritzsche Sent: Tuesday, July 04, 2006 8:02 AM To: [email protected] Subject: Re: [Expat-discuss] Expat and C++ ? On Tue, 4 Jul 2006 [email protected] wrote: > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 03 Jul 2006 19:19:21 -0400 > From: hymedia <[email protected]> > Subject: Re: [Expat-discuss] Expat and C++ ? > To: [email protected] > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > Hi all! > > Anyone have an exemple on how to wrap expat2 in a c++ class witout static or > global functions? Maybe something along the following lines... struct Wrapper { XML_Parser m_parser; void init( const XML_Char* encoding, const XML_Char* seperator) { m_parser = XML_ParserCreate_MM( encoding, 0, // memsuite seperator); // namespace seperator if (!m_parser) return; // Set the user data used in callbacks XML_SetUserData(m_parser, (void *) this); } void fini() { if (m_parser) XML_ParserFree(m_parser); m_parser = 0; } bool parse( const char* buffer, int length, bool isFinal) { assert(m_parser != NULL); // get the length if not specified if (length < 0) length = strlen(buffer); // invoke the parser return XML_Parse(m_parser,buffer,length,isFinal)!=0; } ... }; Hope it helps, Ali _______________________________________________ Expat-discuss mailing list [email protected] http://mail.libexpat.org/mailman/listinfo/expat-discuss