Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUIConfig_xmlHandler.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002     filename:   CEGUIConfig_xmlHandler.cpp
00003     created:    17/7/2004
00004     author:     Paul D Turner
00005     
00006     purpose:    Implements configuration file parser
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011  
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016  
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021  
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #include "CEGUIConfig_xmlHandler.h"
00027 #include "CEGUIExceptions.h"
00028 #include "CEGUISystem.h"
00029 #include "CEGUIXMLAttributes.h"
00030 
00031 
00032 // Start of CEGUI namespace section
00033 namespace CEGUI
00034 {
00035     /*************************************************************************
00036         Implementation Constants
00037     *************************************************************************/
00038     const String Config_xmlHandler::CEGUIConfigElement( (utf8*)"CEGUIConfig" );
00039     const char  Config_xmlHandler::ConfigLogfileAttribute[]         = "Logfile";
00040     const char  Config_xmlHandler::ConfigSchemeAttribute[]          = "Scheme";
00041     const char  Config_xmlHandler::ConfigLayoutAttribute[]          = "Layout";
00042     const char  Config_xmlHandler::ConfigDefaultFontAttribute[]     = "DefaultFont";
00043     const char  Config_xmlHandler::ConfigInitScriptAttribute[]      = "InitScript";
00044     const char  Config_xmlHandler::ConfigTerminateScriptAttribute[] = "TerminateScript";
00045     const char  Config_xmlHandler::ConfigDefaultResourceGroupAttribute[] = "DefaultResourceGroup";
00046     const char  Config_xmlHandler::ConfigLoggingLevelAttribute[]    = "LoggingLevel";
00047 
00048     void Config_xmlHandler::elementStart(const String& element, const XMLAttributes& attributes)
00049     {
00050         // handle root CEGUIConfig element
00051         if (element == CEGUIConfigElement)
00052         {
00053             d_logFilename           = attributes.getValueAsString(ConfigLogfileAttribute);
00054             d_schemeFilename        = attributes.getValueAsString(ConfigSchemeAttribute);
00055             d_layoutFilename        = attributes.getValueAsString(ConfigLayoutAttribute);
00056             d_initScriptFilename    = attributes.getValueAsString(ConfigInitScriptAttribute);
00057             d_termScriptFilename    = attributes.getValueAsString(ConfigTerminateScriptAttribute);
00058             d_defaultFontName       = attributes.getValueAsString(ConfigDefaultFontAttribute);
00059             d_defaultResourceGroup  = attributes.getValueAsString(ConfigDefaultResourceGroupAttribute);
00060 
00061             // handle logging level
00062             String logLevelStr = attributes.getValueAsString(ConfigLoggingLevelAttribute, "Standard");
00063 
00064             if (logLevelStr == "Errors")
00065             {
00066                 d_logLevel = Errors;
00067             }
00068             else if (logLevelStr == "Informative")
00069             {
00070                 d_logLevel = Informative;
00071             }
00072             else if (logLevelStr == "Insane")
00073             {
00074                 d_logLevel = Insane;
00075             }
00076             else
00077             {
00078                 d_logLevel = Standard;
00079             }
00080         }
00081         // anything else is an error which *should* have already been caught by XML validation
00082         else
00083         {
00084             String message("Config_xmlHandler::startElement - Unexpected data was found while parsing the configuration file: '" + element + "' is unknown.");
00085 
00086             // throw a std::exception (because it won't try and use logger)
00087             throw message.c_str();
00088         }
00089 
00090     }
00091 
00092 } // End of  CEGUI namespace section

Generated on Wed Sep 7 09:56:30 2005 for Crazy Eddies GUI System by  doxygen 1.4.3