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

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 "CEGUIXmlHandlerHelper.h"
00030 
00031 #include "xercesc/sax2/SAX2XMLReader.hpp"
00032 #include "xercesc/sax2/XMLReaderFactory.hpp"
00033 
00034 
00035 // Start of CEGUI namespace section
00036 namespace CEGUI
00037 {
00038 /*************************************************************************
00039         Implementation Constants
00040 *************************************************************************/
00041 const String Config_xmlHandler::CEGUIConfigElement( (utf8*)"CEGUIConfig" );
00042 const char      Config_xmlHandler::ConfigLogfileAttribute[]                     = "Logfile";
00043 const char      Config_xmlHandler::ConfigSchemeAttribute[]                      = "Scheme";
00044 const char      Config_xmlHandler::ConfigLayoutAttribute[]                      = "Layout";
00045 const char      Config_xmlHandler::ConfigDefaultFontAttribute[]         = "DefaultFont";
00046 const char      Config_xmlHandler::ConfigInitScriptAttribute[]          = "InitScript";
00047 const char      Config_xmlHandler::ConfigTerminateScriptAttribute[]     = "TerminateScript";
00048 const char  Config_xmlHandler::ConfigDefaultResourceGroupAttribute[] = "DefaultResourceGroup";
00049 
00050 void Config_xmlHandler::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const XERCES_CPP_NAMESPACE::Attributes& attrs)
00051 {
00052         XERCES_CPP_NAMESPACE_USE
00053         String element(XmlHandlerHelper::transcodeXmlCharToString(localname));
00054 
00055         // handle root CEGUIConfig element
00056         if (element == CEGUIConfigElement)
00057         {
00058                 d_logFilename                   = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigLogfileAttribute);
00059                 d_schemeFilename                = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigSchemeAttribute);
00060                 d_layoutFilename                = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigLayoutAttribute);
00061                 d_initScriptFilename    = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigInitScriptAttribute);
00062                 d_termScriptFilename    = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigTerminateScriptAttribute);
00063         d_defaultFontName               = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigDefaultFontAttribute);
00064         d_defaultResourceGroup  = XmlHandlerHelper::getAttributeValueAsString(attrs, ConfigDefaultResourceGroupAttribute);
00065         }
00066         // anything else is an error which *should* have already been caught by XML validation
00067         else
00068         {
00069                 String message("Config_xmlHandler::startElement - Unexpected data was found while parsing the configuration file: '" + element + "' is unknown.");
00070 
00071                 // throw a std::exception (because it won't try and use logger)
00072                 throw message.c_str();
00073         }
00074 
00075 }
00076 
00077 
00078 void Config_xmlHandler::warning(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
00079 {
00080         throw(exc);
00081 }
00082 
00083 void Config_xmlHandler::error(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
00084 {
00085         throw(exc);
00086 }
00087 
00088 void Config_xmlHandler::fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
00089 {
00090         throw(exc);
00091 }
00092 
00093 } // End of  CEGUI namespace section

Generated on Wed Feb 16 12:41:05 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1