CEGUIXercesParser.h

00001 /************************************************************************
00002     filename:   CEGUIXercesParser.h
00003     created:    Sat Mar 12 2005
00004     author:     Paul D Turner
00005 *************************************************************************/
00006 /*************************************************************************
00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00009  
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2.1 of the License, or (at your option) any later version.
00014  
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Lesser General Public License for more details.
00019  
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 *************************************************************************/
00024 #ifndef _CEGUIXercesParser_h_
00025 #define _CEGUIXercesParser_h_
00026 
00027 #include "CEGUIXMLParser.h"
00028 
00029 // Xerces-C includes
00030 #include <xercesc/framework/MemBufInputSource.hpp>
00031 #include <xercesc/util/PlatformUtils.hpp>
00032 #include <xercesc/util/TransService.hpp>
00033 #include <xercesc/util/XMLString.hpp>
00034 #include <xercesc/sax2/Attributes.hpp>
00035 #include <xercesc/sax2/DefaultHandler.hpp>
00036 #include <xercesc/sax2/SAX2XMLReader.hpp>
00037 #include <xercesc/sax2/XMLReaderFactory.hpp>
00038 
00039 // Start of CEGUI namespace section
00040 namespace CEGUI
00041 {
00042     class XercesHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
00043     {
00044     public:
00045         XercesHandler(XMLHandler& handler);
00046         ~XercesHandler(void);
00047 
00048         // Implementation of methods in Xerces DefaultHandler.
00049         void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const XERCES_CPP_NAMESPACE::Attributes& attrs);
00050         void endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname);
00051         void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
00052         void error (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
00053         void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
00054 
00055     protected:
00056         XMLHandler& d_handler;      
00057     };
00058 
00063     class XercesParser : public XMLParser
00064     {
00065     public:
00066         XercesParser(void);
00067         ~XercesParser(void);
00068 
00069         // Implementation of public abstract interface
00070         void parseXMLFile(XMLHandler& handler, const String& filename, const String& schemaName, const String& resourceGroup);
00071 
00072         // Internal methods
00077         static void populateAttributesBlock(const XERCES_CPP_NAMESPACE::Attributes& src, XMLAttributes& dest);
00078 
00083         static String transcodeXmlCharToString(const XMLCh* const xmlch_str);
00084 
00085     protected:
00086         static void initialiseSchema(XERCES_CPP_NAMESPACE::SAX2XMLReader* reader, const String& schemaName, const String& xmlFilename, const String& resourceGroup);
00087         static XERCES_CPP_NAMESPACE::SAX2XMLReader* createReader(XERCES_CPP_NAMESPACE::DefaultHandler& handler);
00088         static void doParse(XERCES_CPP_NAMESPACE::SAX2XMLReader* parser, const String& xmlFilename, const String& resourceGroup);
00089 
00090         // Implementation of abstract interface.
00091         bool initialiseImpl(void);
00092         void cleanupImpl(void);
00093     };
00094 
00095 } // End of  CEGUI namespace section
00096 
00097 
00098 #endif  // end of guard _CEGUIXercesParser_h_

Generated on Sat Nov 26 09:34:49 2005 for Crazy Eddies GUI System by  doxygen 1.4.5