[Expat-discuss] cannot convert parameter from 'void (void *, const char *, const char ** )'

allan.saywitz at pb.com allan.saywitz at pb.com
Wed Mar 31 10:11:21 EST 2004






If you are using C++, might as well take advantage of inheritence and use a
base class to store all the generic code that talks to expat.  Then your
derived class only needs one handler, not two.  Also, you can reuse all the
code in your next project by just reusing the base class.  Similar to Scott
Meyers approach to implementing reference counting of strings by using a
base class to do it.  See his book "More Effective C++" for details.

Included is some working code.

Basically it works like this:

// Usage: Simple derive a class from XMLExpatParser and override callbacks.
//
//        class MyParser : public XMLExpatParser
//        {
//           virtual void startElement(const string& sName, const
VectorString& attributes);
//           virtual void endElement(const string& sName);
//           virtual void charData(const string& sValue);
//        }
//
//        MyParser parser;
//
//        if (parser.create())
//        {
//           parser.parse(xmlBuffer, length)
//        }
//
//
// How it works:
//
//   The *userData which expat maintains is simply a pointer to an instance
of your object.
//   Then the expat callback functions simply call your object's overridden
virtual method.
//   If your object doesn't override a method, the empty method in the base
class is called.

Hope this helps

allan

(See attached file: TestExpatParser.zip)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestExpatParser.zip
Type: application/zip
Size: 6255 bytes
Desc: not available
Url : http://mail.libexpat.org/pipermail/expat-discuss/attachments/20040331/f8c9729c/TestExpatParser.zip


More information about the Expat-discuss mailing list