Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

sd_DOMStream.h

00001 #ifndef lak_DOMStream_h
00002 #define lak_DOMStream_h
00003 
00004 #include <qxml.h>
00005 #include <qdom.h>
00006 #include <set>
00007 
00008 namespace streamdom
00009 {
00080   class DOMStream : public QXmlContentHandler
00081   {
00082   public:
00090     class ElementHandler
00091     {
00092     public:
00093       virtual ~ElementHandler()
00094       {
00095       }
00101       virtual void handleElement( const QDomElement& e ) = 0;
00102     }
00103     ;
00104     
00116     class IgnoredElementHandler
00117     {
00118     public:
00122       virtual void handleElementStart( const QString& qName,
00123                                        const QXmlAttributes & atts )
00124       {
00125       }
00126             
00128       virtual void handleElementEnd( const QString& qName )
00129       {
00130       }
00131 
00132       virtual ~IgnoredElementHandler()
00133       {
00134       }
00135     };
00136     
00137 
00138   public:
00139     virtual bool startElement  ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts );
00140     
00141     virtual bool endElement ( const QString & namespaceURI, const QString & localName, const QString & qName ) ;
00142 
00143     virtual bool characters ( const QString & ch ) ;
00144     
00145     virtual ~DOMStream();
00146 
00157     void ignoreElement(const QString& name);
00158 
00165     void addElementHandler( ElementHandler* e );
00166 
00167     void removeElementHandler( ElementHandler* e );
00168 
00175     void addIgnoredElementHandler( IgnoredElementHandler* e );
00176 
00177     void removeIgnoredElementHandler( IgnoredElementHandler* e );
00178     
00179     DOMStream() {}
00180 
00181   private:
00183     DOMStream(const DOMStream&);
00185     DOMStream& operator =(const DOMStream&);
00186 
00187   public:
00188     virtual void setDocumentLocator ( QXmlLocator * locator ) 
00189     {
00190     }
00191     
00192     virtual bool startDocument () 
00193     {
00194       return true;
00195     }
00196     
00197     virtual bool endDocument () 
00198     {
00199       return true;
00200     }
00201     
00202     virtual bool startPrefixMapping ( const QString & prefix, 
00203                                       const QString & uri ) 
00204     {
00205       return true;
00206     }
00207     virtual bool endPrefixMapping ( const QString & prefix ) 
00208     {
00209       return true;
00210     }
00211 
00212     virtual bool ignorableWhitespace ( const QString & ch ) 
00213     {
00214       return true;
00215     }
00216     virtual bool processingInstruction ( const QString & target, 
00217                                          const QString & data ) 
00218     {
00219       return true;
00220     }
00221     virtual bool skippedEntity ( const QString & name ) 
00222     {
00223       return true;
00224     }
00225     virtual QString errorString () 
00226     {
00227       return QString();
00228     }
00229 
00230 
00231   private:
00232     // SAX state variables
00233     QString chars;
00234     QDomDocument doc;
00235     QDomElement parentElement;
00236     QDomElement topMostElement;
00237   
00238     // output variables
00239     typedef std::set< ElementHandler* > Handlers;
00240     std::set< QString > elementsToIgnore;
00241     Handlers handlers;
00242 
00243     typedef std::set< IgnoredElementHandler* > IgnoredHandlers;
00244     IgnoredHandlers ignoredHandlers;
00245 
00246   }
00247   ;
00248 }
00249 
00250 #endif

Generated at Fri Jan 4 15:19:10 2002 for streamdom by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001