[Expat-discuss] Expat and C++ ?
hymedia
hymedia at videotron.ca
Tue Jul 4 20:57:10 CEST 2006
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: expat-discuss-bounces at libexpat.org
[mailto:expat-discuss-bounces at libexpat.org] On Behalf Of Albrecht Fritzsche
Sent: Tuesday, July 04, 2006 8:02 AM
To: expat-discuss at libexpat.org
Subject: Re: [Expat-discuss] Expat and C++ ?
On Tue, 4 Jul 2006 expat-discuss-request at libexpat.org wrote:
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 03 Jul 2006 19:19:21 -0400
> From: hymedia <hymedia at videotron.ca>
> Subject: Re: [Expat-discuss] Expat and C++ ?
> To: expat-discuss at libexpat.org
> Message-ID: <0J1U00FS7OSF8P70 at VL-MO-MR004.ip.videotron.ca>
> 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
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss
More information about the Expat-discuss
mailing list