[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

SAX2/C++ interface draft [Was: Re: Request for Discussion: SAX 1.0 in C+

  • From: Michael Fuller <msf@m...>
  • To: Richard Anderson <rja@a...>
  • Date: Mon, 6 Dec 1999 20:13:59 +1100

sax2 c
On Fri, Dec 03, 1999 at 08:11:53PM -0000, Richard Anderson wrote:
> How about focusing on SAX/2, and making the first C/C++ SAX interface
> actually SAX 2 so we kill two birds with one stone ?

Good idea!

Here's a [hasty] conversion of the SAX2 Java classes into C++, 
along the lines of David and James' posted SAX 1.0/C++ headers
I've used exception specifiers for consistency with the original Java.

// SAX2Decl.h

namespace SAX
{
    class Configurable;
    class DTDHandler;
    class DocumentHandler;
    class EntityResolver;
    class ErrorHandler;
    class InputSource;
    class Parser;
    class SAXException;

    class Configurable
    {
    public:
	virtual void setFeature(SAXString featureId, bool state)
					    throw(SAXException) = 0;
	virtual bool getFeature(SAXString featureId)
					    throw(SAXException) = 0;
	virtual void setProperty(SAXString propertyId, void * value)
					    throw(SAXException) = 0;
	virtual void * getProperty(SAXString propertyId)
					    throw(SAXException) = 0;
    private:
	void operator delete (void *);
    }

    class ConfigurableParserAdapter : public Parser, public Configurable
    {
    public
	ConfigurableParserAdapter(Parser& parser);

	// SAX 1.0 methods
	void setLocale(const char * locale)		throw(SAXException);
	void setEntityResolver(EntityResolver& resolver)
       	void setDTDHandler(DTDHandler& handler)
	void setDocumentHandler(DocumentHandler& handler)
       	void setErrorHandler(ErrorHandler& handler)
	void parse(const InputSource& source)		throw(SAXException);
	void parse(SAXString systemId)			throw(SAXException);
    
	// SAX2 methods
	void setFeature(SAXString featureId, bool state) throw(SAXException);
	bool getFeature(SAXString featureId)		throw(SAXException);
	void setProperty(SAXString propertyId, void * value)
							throw(SAXException);
	void * getProperty(SAXString propertyId)	throw(SAXException);
    private:
	void operator delete (void *);
    }

    class DeclHandler
    {
    public:
	virtual void elementDecl(SAXString name, SAXString model)
						throw(SAXException) = 0;

	virtual void attributeDecl(SAXString eName,
				   SAXString aName,
				   SAXString type,
				   SAXString valueDefault,
				   SAXString value)
						throw(SAXException) = 0;

	virtual void internalEntityDecl(SAXString name, SAXString value)
						throw(SAXException) = 0;

	virtual void externalEntityDecl(SAXString name,
					SAXString publicId,
					SAXString systemId)
						throw(SAXException) = 0;
    private:
	void operator delete (void *);
    }

    class LexicalHandler
    {
    public:
	virtual void startDTD(SAXString name,
			      SAXString publicId,
			      SAXString systemId)
					throw(SAXException) = 0;
				    
	virtual void endDTD()		throw(SAXException) = 0;

	virtual void startEntity(SAXString name)
					throw(SAXException) = 0;
	virtual void endEntity(SAXString name)
					throw(SAXException) = 0;

	virtual void startCDATA()	throw(SAXException) = 0;
	virtual void endCDATA()		throw(SAXException) = 0;

	virtual void comment(const SAXChar * ch, int length)
					throw(SAXException) = 0;

    private:
	void operator delete (void *);
    }

    class NamespaceHandler
    {
    public:
	virtual void startNamespaceDeclScope(SAXString prefix, SAXString uri)
					throw(SAXException) = 0;
	virtual void endNamespaceDeclScope(SAXString prefix)
					throw(SAXException) = 0;
    private:
	void operator delete (void *);
    }

    class SAXNotRecognizedException : public SAXException
    {
    public:
	SAXNotRecognizedException(SAXString message);
    private:
	void operator delete (void *);
    }

    class SAXNotSupportedException : public SAXException
    {
    public:
	SAXNotSupportedException(SAXString message);
    private:
	void operator delete (void *);
    }
}


Michael
-- 
http://www.mds.rmit.edu.au/~msf/
Multimedia Databases Group, RMIT, Australia.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.