Crazy Eddie's GUI System 0.8.7
Config_xmlHandler.h
1/***********************************************************************
2 created: Sat Jul 25 2009
3 author: Paul D Turner <paul@cegui.org.uk>
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2009 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 _CEGUIConfig_xmlHandler_h_
28#define _CEGUIConfig_xmlHandler_h_
29
30#include "CEGUI/Base.h"
31#include "CEGUI/String.h"
32#include "CEGUI/Logger.h"
33#include "CEGUI/XMLHandler.h"
34#include <vector>
35
36#if defined (_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4251)
39#endif
40
41// Start of CEGUI namespace section
42namespace CEGUI
43{
46{
47public:
50 // xml tag names
51 static const String CEGUIConfigElement;
52 static const String LoggingElement;
53 static const String AutoLoadElement;
54 static const String ResourceDirectoryElement;
55 static const String DefaultResourceGroupElement;
56 static const String ScriptingElement;
57 static const String XMLParserElement;
58 static const String ImageCodecElement;
59 static const String DefaultFontElement;
60 static const String DefaultMouseCursorElement;
61 static const String DefaultTooltipElement;
62 // xml attribute names
63 static const String FilenameAttribute;
64 static const String LevelAttribute;
65 static const String TypeAttribute;
66 static const String GroupAttribute;
67 static const String PatternAttribute;
68 static const String DirectoryAttribute;
69 static const String InitScriptAttribute;
70 static const String TerminateScriptAttribute;
71 static const String ImageAttribute;
72 static const String NameAttribute;
73
76
79
81 void initialiseXMLParser() const;
85 void initialiseLogger(const String& default_filename) const;
91 void loadAutoResources() const;
99 void executeInitScript() const;
102
103 // XMLHandler overrides
104 const String& getSchemaName() const;
106
107 void elementStart(const String& element, const XMLAttributes& attributes);
108 void elementEnd(const String& element);
109
110private:
112 enum ResourceType
113 {
114 RT_IMAGESET,
115 RT_FONT,
116 RT_SCHEME,
117 RT_LOOKNFEEL,
118 RT_LAYOUT,
119 RT_SCRIPT,
120 RT_XMLSCHEMA,
121 RT_DEFAULT
122 };
123
125 struct ResourceDirectory
126 {
127 String group;
128 String directory;
129 };
130
132 struct DefaultResourceGroup
133 {
134 ResourceType type;
135 String group;
136 };
137
139 struct AutoLoadResource
140 {
141 String type_string;
142 ResourceType type;
143 String group;
144 String pattern;
145 };
146
147 // functions to handle the various elements
148 void handleCEGUIConfigElement(const XMLAttributes& attr);
149 void handleLoggingElement(const XMLAttributes& attr);
150 void handleAutoLoadElement(const XMLAttributes& attr);
151 void handleResourceDirectoryElement(const XMLAttributes& attr);
152 void handleDefaultResourceGroupElement(const XMLAttributes& attr);
153 void handleScriptingElement(const XMLAttributes& attr);
154 void handleXMLParserElement(const XMLAttributes& attr);
155 void handleImageCodecElement(const XMLAttributes& attr);
156 void handleDefaultTooltipElement(const XMLAttributes& attr);
157 void handleDefaultFontElement(const XMLAttributes& attr);
158 void handleDefaultMouseCursorElement(const XMLAttributes& attr);
159
161 ResourceType stringToResourceType(const String& type) const;
163 void autoLoadLookNFeels(const String& pattern, const String& group) const;
165 void autoLoadImagesets(const String& pattern, const String& group) const;
166
168 typedef std::vector<ResourceDirectory
169 CEGUI_VECTOR_ALLOC(ResourceDirectory)> ResourceDirVector;
171 typedef std::vector<DefaultResourceGroup
172 CEGUI_VECTOR_ALLOC(DefaultResourceGroup)> DefaultGroupVector;
174 typedef std::vector<AutoLoadResource
175 CEGUI_VECTOR_ALLOC(AutoLoadResource)> AutoResourceVector;
177 String d_logFileName;
179 LoggingLevel d_logLevel;
181 String d_xmlParserName;
183 String d_imageCodecName;
185 String d_defaultFont;
187 String d_defaultMouseImage;
189 String d_defaultTooltipType;
191 String d_scriptingInitScript;
193 String d_scriptingTerminateScript;
195 ResourceDirVector d_resourceDirectories;
197 DefaultGroupVector d_defaultResourceGroups;
199 AutoResourceVector d_autoLoadResources;
200};
201
202} // End of CEGUI namespace section
203
204#if defined (_MSC_VER)
205# pragma warning(pop)
206#endif
207
208#endif // end of guard _CEGUIConfig_xmlHandler_h_
Handler class used to parse the Configuration XML file.
Definition: Config_xmlHandler.h:46
void initialiseLogger(const String &default_filename) const
Initialise the CEGUI Logger according to info parsed from config.
void initialiseDefaultFont() const
initialise the system default font according to the config.
~Config_xmlHandler()
Destructor.
void loadAutoResources() const
Auto-load all resources specified in the config.
const String & getTerminateScriptName() const
return the name of the terminate script from the config (hacky!)
void initialiseDefaultMouseCursor() const
initialise the system default mouse cursor image according to the config.
const String & getSchemaName() const
Retrieves the schema file name to use with resources handled by this handler.
const String & getDefaultResourceGroup() const
Retrieves the default resource group to be used when handling files.
Config_xmlHandler()
Constructor.
void initialiseXMLParser() const
Initialise the CEGUI XMLParser according to info parsed from config.
void elementStart(const String &element, const XMLAttributes &attributes)
Method called to notify the handler at the start of each XML element encountered.
void executeInitScript() const
execute the init script as specified in the config.
void initialiseImageCodec() const
Initialise the CEGUI ImageCodec according to info parsed from config.
void initialiseDefaultResourceGroups() const
Set default resource groups according to those in the config.
void initialiseDefaulTooltip() const
initialise the system default tooltip according to the config.
static const String CEGUIConfigSchemaName
Name of xsd schema file used for validation.
Definition: Config_xmlHandler.h:49
void initialiseResourceGroupDirectories() const
Set resource group dirs read from the config. (DefaultResourceProvider only).
void elementEnd(const String &element)
Method called to notify the handler at the end of each XML element encountered.
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
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
LoggingLevel
Enumeration of logging levels.
Definition: Logger.h:57