Crazy Eddies GUI System  0.7.8
CEGUIConfig_xmlHandler.h
1 /***********************************************************************
2  filename: CEGUIConfig_xmlHandler.h
3  created: Sat Jul 25 2009
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIConfig_xmlHandler_h_
29 #define _CEGUIConfig_xmlHandler_h_
30 
31 #include "CEGUIBase.h"
32 #include "CEGUIString.h"
33 #include "CEGUILogger.h"
34 #include "CEGUIXMLHandler.h"
35 #include <vector>
36 
37 #if defined (_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
47 {
48 public:
51  // xml tag names
52  static const String CEGUIConfigElement;
53  static const String LoggingElement;
54  static const String AutoLoadElement;
55  static const String ResourceDirectoryElement;
56  static const String DefaultResourceGroupElement;
57  static const String ScriptingElement;
58  static const String XMLParserElement;
59  static const String ImageCodecElement;
60  static const String DefaultFontElement;
61  static const String DefaultMouseCursorElement;
62  static const String DefaultTooltipElement;
63  static const String DefaultGUISheetElement;
64  // xml attribute names
65  static const String FilenameAttribute;
66  static const String LevelAttribute;
67  static const String TypeAttribute;
68  static const String GroupAttribute;
69  static const String PatternAttribute;
70  static const String DirectoryAttribute;
71  static const String InitScriptAttribute;
72  static const String TerminateScriptAttribute;
73  static const String ImagesetAttribute;
74  static const String ImageAttribute;
75  static const String NameAttribute;
76 
79 
82 
84  void initialiseXMLParser() const;
86  void initialiseImageCodec() const;
88  void initialiseLogger(const String& default_filename) const;
94  void loadAutoResources() const;
96  void initialiseDefaultFont() const;
98  void initialiseDefaultMouseCursor() const;
100  void initialiseDefaulTooltip() const;
102  void initialiseDefaultGUISheet() const;
104  void executeInitScript() const;
106  const String& getTerminateScriptName() const;
107 
108  // XMLHandler overrides
109  void elementStart(const String& element, const XMLAttributes& attributes);
110  void elementEnd(const String& element);
111 
112 private:
114  enum ResourceType
115  {
116  RT_IMAGESET,
117  RT_FONT,
118  RT_SCHEME,
119  RT_LOOKNFEEL,
120  RT_LAYOUT,
121  RT_SCRIPT,
122  RT_XMLSCHEMA,
123  RT_DEFAULT
124  };
125 
127  struct ResourceDirectory
128  {
129  String group;
130  String directory;
131  };
132 
134  struct DefaultResourceGroup
135  {
136  ResourceType type;
137  String group;
138  };
139 
141  struct AutoLoadResource
142  {
143  String type_string;
144  ResourceType type;
145  String group;
146  String pattern;
147  };
148 
149  // functions to handle the various elements
150  void handleCEGUIConfigElement(const XMLAttributes& attr);
151  void handleLoggingElement(const XMLAttributes& attr);
152  void handleAutoLoadElement(const XMLAttributes& attr);
153  void handleResourceDirectoryElement(const XMLAttributes& attr);
154  void handleDefaultResourceGroupElement(const XMLAttributes& attr);
155  void handleScriptingElement(const XMLAttributes& attr);
156  void handleXMLParserElement(const XMLAttributes& attr);
157  void handleImageCodecElement(const XMLAttributes& attr);
158  void handleDefaultTooltipElement(const XMLAttributes& attr);
159  void handleDefaultGUISheetElement(const XMLAttributes& attr);
160  void handleDefaultFontElement(const XMLAttributes& attr);
161  void handleDefaultMouseCursorElement(const XMLAttributes& attr);
162 
164  ResourceType stringToResourceType(const String& type) const;
166  void autoLoadLayouts(const String& pattern, const String& group) const;
168  void autoLoadLookNFeels(const String& pattern, const String& group) const;
169 
171  typedef std::vector<ResourceDirectory> ResourceDirVector;
173  typedef std::vector<DefaultResourceGroup> DefaultGroupVector;
175  typedef std::vector<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_defaultMouseImageset;
189  String d_defaultMouseImage;
191  String d_defaultTooltipType;
193  String d_defaultGUISheet;
195  String d_scriptingInitScript;
197  String d_scriptingTerminateScript;
199  ResourceDirVector d_resourceDirectories;
201  DefaultGroupVector d_defaultResourceGroups;
203  AutoResourceVector d_autoLoadResources;
204 };
205 
206 } // End of CEGUI namespace section
207 
208 #if defined (_MSC_VER)
209 # pragma warning(pop)
210 #endif
211 
212 #endif // end of guard _CEGUIConfig_xmlHandler_h_