source: OGRE/trunk/ogrenew/Dependencies/include/CEGUI/CEGUIXercesParser.h @ 657

Revision 657, 4.1 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/************************************************************************
2    filename:   CEGUIXercesParser.h
3    created:    Sat Mar 12 2005
4    author:     Paul D Turner
5*************************************************************************/
6/*************************************************************************
7    Crazy Eddie's GUI System (http://www.cegui.org.uk)
8    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
9 
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 2.1 of the License, or (at your option) any later version.
14 
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19 
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23*************************************************************************/
24#ifndef _CEGUIXercesParser_h_
25#define _CEGUIXercesParser_h_
26
27#include "CEGUIXMLParser.h"
28
29// Xerces-C includes
30#include <xercesc/framework/MemBufInputSource.hpp>
31#include <xercesc/util/PlatformUtils.hpp>
32#include <xercesc/util/TransService.hpp>
33#include <xercesc/util/XMLString.hpp>
34#include <xercesc/sax2/Attributes.hpp>
35#include <xercesc/sax2/DefaultHandler.hpp>
36#include <xercesc/sax2/SAX2XMLReader.hpp>
37#include <xercesc/sax2/XMLReaderFactory.hpp>
38
39// Start of CEGUI namespace section
40namespace CEGUI
41{
42    class XercesHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
43    {
44    public:
45        XercesHandler(XMLHandler& handler);
46        ~XercesHandler(void);
47
48        // Implementation of methods in Xerces DefaultHandler.
49        void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const XERCES_CPP_NAMESPACE::Attributes& attrs);
50        void endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname);
51        void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
52        void error (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
53        void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
54
55    protected:
56        XMLHandler& d_handler;      //!< This is the 'real' CEGUI based handler which we interface via.
57    };
58
59    /*!
60    \brief
61        Implementation of XMLParser using Xerces-C++
62     */
63    class XercesParser : public XMLParser
64    {
65    public:
66        XercesParser(void);
67        ~XercesParser(void);
68
69        // Implementation of public abstract interface
70        void parseXMLFile(XMLHandler& handler, const String& filename, const String& schemaName, const String& resourceGroup);
71
72        // Internal methods
73        /*!
74        \brief
75            Populate the CEGUI::XMLAttributes object with attribute data from the Xerces attributes block.
76         */
77        static void populateAttributesBlock(const XERCES_CPP_NAMESPACE::Attributes& src, XMLAttributes& dest);
78
79        /*!
80        \brief
81            Return a CEGUI::String containing the Xerces XMLChar string data in \a xmlch_str.
82         */
83        static String transcodeXmlCharToString(const XMLCh* const xmlch_str);
84
85    protected:
86        static void initialiseSchema(XERCES_CPP_NAMESPACE::SAX2XMLReader* reader, const String& schemaName, const String& xmlFilename, const String& resourceGroup);
87        static XERCES_CPP_NAMESPACE::SAX2XMLReader* createReader(XERCES_CPP_NAMESPACE::DefaultHandler& handler);
88        static void doParse(XERCES_CPP_NAMESPACE::SAX2XMLReader* parser, const String& xmlFilename, const String& resourceGroup);
89
90        // Implementation of abstract interface.
91        bool initialiseImpl(void);
92        void cleanupImpl(void);
93    };
94
95} // End of  CEGUI namespace section
96
97
98#endif  // end of guard _CEGUIXercesParser_h_
Note: See TracBrowser for help on using the repository browser.