About a C++ interface for event handling

Didier PH Martin martind at netfolder.com
Sun Dec 12 22:26:04 GMT 1999


Hi,

In order to get a good C++ mapping for XML parsing and also take the
occasion to merge with the SGML world so that it could be possible to have a
parser to do both, here is waht we already have as interface in OpenSP (the
version 1.14 soon to be released)

class document handler
{
  virtual void appinfo(const AppinfoEvent &) = 0;
  virtual void startDtd(const StartDtdEvent &) = 0;
  virtual void endDtd(const EndDtdEvent &) = 0;
  virtual void endProlog(const EndPrologEvent &) = 0;
  virtual void startElement(const StartElementEvent &) =0 ;
  virtual void endElement(const EndElementEvent &) =0 ;
  virtual void data(const DataEvent &) = 0 ;
  virtual void sdata(const SdataEvent &) = 0;
  virtual void pi(const PiEvent &) = 0;
  virtual void externalDataEntityRef(const ExternalDataEntityRefEvent &) =
0;
  virtual void subdocEntityRef(const SubdocEntityRefEvent &) = 0;
  virtual void nonSgmlChar(const NonSgmlCharEvent &) = 0;
  virtual void commentDecl(const CommentDeclEvent &) = 0;
  virtual void markedSectionStart(const MarkedSectionStartEvent &) = 0;
  virtual void markedSectionEnd(const MarkedSectionEndEvent &) = 0;
  virtual void ignoredChars(const IgnoredCharsEvent &) = 0;
  virtual void generalEntity(const GeneralEntityEvent &) = 0;
  virtual void error(const ErrorEvent &) = 0 ;
  virtual void openEntityChange(const OpenEntityPtr &) = 0;
}

Because it is more convenient in C++ to work either with classes or struct,
each member provide an event structure to the interface implementation.
Obvioiusly, for XML some of these members are useless so waht we could have
now is an XML interface having less members and having the SGML interface
having more members and which inherits from the XML interface. This way the
set/superset relationship between SGML and XML would also be expressed with
a class superclass inheritance.

So, for XML what would be useful is:

class IXMLDocumentHandler
{
  virtual void startDtd(const StartDtdEvent &) = 0;
  virtual void endDtd(const EndDtdEvent &) = 0;
  virtual void startElement(const StartElementEvent &) =0 ;
  virtual void endElement(const EndElementEvent &) =0 ;
  virtual void pi(const PiEvent &) = 0;
  virtual void externalDataEntityRef(const ExternalDataEntityRefEvent &) =
0;
  virtual void commentDecl(const CommentDeclEvent &) = 0;
  virtual void error(const ErrorEvent &) = 0 ;
}


Did I forgot anything for XML? So the SGMLDocumentHandler interface would
inherit from the XMLDocumentHandler interface and add waht is necessary for
SGML

class ISGMLDocumentHandler: public IXMLDocumentHandler
{
  virtual void endProlog(const EndPrologEvent &) = 0;
  virtual void data(const DataEvent &) = 0 ;
  virtual void sdata(const SdataEvent &) = 0;
  virtual void subdocEntityRef(const SubdocEntityRefEvent &) = 0;
  virtual void nonSgmlChar(const NonSgmlCharEvent &) = 0;
  virtual void markedSectionStart(const MarkedSectionStartEvent &) = 0;
  virtual void markedSectionEnd(const MarkedSectionEndEvent &) = 0;
  virtual void ignoredChars(const IgnoredCharsEvent &) = 0;
  virtual void generalEntity(const GeneralEntityEvent &) = 0;
  virtual void openEntityChange(const OpenEntityPtr &) = 0;
}

Comments?

Cheers
Didier PH Martin
----------------------------------------------
Email: martind at netfolder.com
Conferences:
Web Boston (http://www.mfweb.com)
Markup 99 (http://www.gca.com)
Book:
To come soon: XML Pro published by Wrox Press
Products:
http://www.netfolder.com


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





More information about the Xml-dev mailing list