Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
XMLParserModules/Xerces/XMLParser.h
1/***********************************************************************
2 created: Sat Mar 12 2005
3 author: Paul D Turner
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27#ifndef _CEGUIXercesParser_h_
28#define _CEGUIXercesParser_h_
29
30#include "../../XMLParser.h"
31#include "CEGUI/XMLParserModules/Xerces/XMLParserProperties.h"
32
33#if defined(_MSC_VER)
34# pragma warning(push)
35# pragma warning(disable : 4251)
36#endif
37
38#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
39# ifdef CEGUIXERCESPARSER_EXPORTS
40# define CEGUIXERCESPARSER_API __declspec(dllexport)
41# else
42# define CEGUIXERCESPARSER_API __declspec(dllimport)
43# endif
44#else
45# define CEGUIXERCESPARSER_API
46#endif
47
48
49// Xerces-C includes
50#include <xercesc/framework/MemBufInputSource.hpp>
51#include <xercesc/util/PlatformUtils.hpp>
52#include <xercesc/util/TransService.hpp>
53#include <xercesc/util/XMLString.hpp>
54#include <xercesc/sax2/Attributes.hpp>
55#include <xercesc/sax2/DefaultHandler.hpp>
56#include <xercesc/sax2/SAX2XMLReader.hpp>
57#include <xercesc/sax2/XMLReaderFactory.hpp>
58
59// Start of CEGUI namespace section
60namespace CEGUI
61{
62 class XercesHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
63 {
64 public:
65 XercesHandler(XMLHandler& handler);
66 ~XercesHandler(void);
67
68 // Implementation of methods in Xerces DefaultHandler.
69 void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const XERCES_CPP_NAMESPACE::Attributes& attrs);
70 void endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname);
71#if _XERCES_VERSION >= 30000
72 void characters(const XMLCh* const chars, const XMLSize_t length);
73#else /* _XERCES_VERSION >= 30000 */
74 void characters (const XMLCh *const chars, const unsigned int length);
75#endif /* _XERCES_VERSION >= 30000 */
76 void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
77 void error (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
78 void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exc);
79
80 protected:
82 };
83
88 class CEGUIXERCESPARSER_API XercesParser : public XMLParser
89 {
90 public:
91 XercesParser(void);
92 ~XercesParser(void);
93
94 // Implementation of public abstract interface
95 void parseXML(XMLHandler& handler, const RawDataContainer& source, const String& schemaName);
96
97 // Internal methods
102 static void populateAttributesBlock(const XERCES_CPP_NAMESPACE::Attributes& src, XMLAttributes& dest);
103
115 static String transcodeXmlCharToString(const XMLCh* const xmlch_str, unsigned int length);
116
127 static void setSchemaDefaultResourceGroup(const String& resourceGroup)
128 { d_defaultSchemaResourceGroup = resourceGroup; }
129
138 { return d_defaultSchemaResourceGroup; }
139
140 protected:
141 static void initialiseSchema(XERCES_CPP_NAMESPACE::SAX2XMLReader* reader, const String& schemaName);
142 static XERCES_CPP_NAMESPACE::SAX2XMLReader* createReader(XERCES_CPP_NAMESPACE::DefaultHandler& handler);
143 static void doParse(XERCES_CPP_NAMESPACE::SAX2XMLReader* parser, const RawDataContainer& source);
144
145 // Implementation of abstract interface.
146 bool initialiseImpl(void);
147 void cleanupImpl(void);
148
154 };
155
156} // End of CEGUI namespace section
157
158#if defined(_MSC_VER)
159# pragma warning(pop)
160#endif
161
162#endif // end of guard _CEGUIXercesParser_h_
Class used as the databuffer for loading files throughout the library.
Definition DataContainer.h:44
String class used within the GUI system.
Definition String.h:64
Class representing a block of attributes associated with an XML element.
Definition XMLAttributes.h:48
Definition XMLHandler.h:37
This is an abstract class that is used by CEGUI to interface with XML parser libraries.
Definition XMLParser.h:44
Definition XMLParserModules/Xerces/XMLParser.h:63
XMLHandler & d_handler
This is the 'real' CEGUI based handler which we interface via.
Definition XMLParserModules/Xerces/XMLParser.h:81
Property to access the resource group used to load .xsd schema files.
Definition XMLParserProperties.h:48
Implementation of XMLParser using Xerces-C++.
Definition XMLParserModules/Xerces/XMLParser.h:89
static String d_defaultSchemaResourceGroup
holds the default resource group ID for loading schemas.
Definition XMLParserModules/Xerces/XMLParser.h:150
static void populateAttributesBlock(const XERCES_CPP_NAMESPACE::Attributes &src, XMLAttributes &dest)
Populate the CEGUI::XMLAttributes object with attribute data from the Xerces attributes block.
static void setSchemaDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading schema files.
Definition XMLParserModules/Xerces/XMLParser.h:127
void cleanupImpl(void)
abstract method which cleans up the XMLParser after use.
static XercesParserProperties::SchemaDefaultResourceGroup s_schemaDefaultResourceGroupProperty
Property for accessing the default schema resource group ID.
Definition XMLParserModules/Xerces/XMLParser.h:153
bool initialiseImpl(void)
abstract method which initialises the XMLParser ready for use.
void parseXML(XMLHandler &handler, const RawDataContainer &source, const String &schemaName)
abstract method which initiates parsing of an XML.
static const String & getSchemaDefaultResourceGroup()
Returns the default resource group used when loading schema files.
Definition XMLParserModules/Xerces/XMLParser.h:137
static String transcodeXmlCharToString(const XMLCh *const xmlch_str, unsigned int length)
Return a CEGUI::String containing the Xerces XMLChar string data in xmlch_str.
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1