SUMOSAXHandler.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // SAX-handler base for SUMO-files
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <string>
00031 #include <iostream>
00032 #include <utils/xml/GenericSAXHandler.h>
00033 #include <utils/common/MsgHandler.h>
00034 #include <utils/common/TplConvert.h>
00035 #include <utils/common/ToString.h>
00036 #include "SUMOXMLDefinitions.h"
00037 #include "SUMOSAXHandler.h"
00038 
00039 #ifdef CHECK_MEMORY_LEAKS
00040 #include <foreign/nvwa/debug_new.h>
00041 #endif // CHECK_MEMORY_LEAKS
00042 
00043 
00044 // ===========================================================================
00045 // method definitions
00046 // ===========================================================================
00047 SUMOSAXHandler::SUMOSAXHandler(const std::string &file) throw()
00048         : GenericSAXHandler(sumotags, sumoattrs, file) {}
00049 
00050 
00051 SUMOSAXHandler::~SUMOSAXHandler() throw() {}
00052 
00053 
00054 std::string
00055 SUMOSAXHandler::buildErrorMessage(const SAXParseException& exception) throw() {
00056     std::ostringstream buf;
00057     char *pMsg = XMLString::transcode(exception.getMessage());
00058     buf << pMsg << std::endl;
00059     buf << " In file '" << getFileName() << "'" << std::endl;
00060     buf << " At line/column " << exception.getLineNumber()+1
00061     << '/' << exception.getColumnNumber() << "." << std::endl;
00062     XMLString::release(&pMsg);
00063     return buf.str();
00064 }
00065 
00066 
00067 void
00068 SUMOSAXHandler::warning(const SAXParseException& exception) throw() {
00069     MsgHandler::getWarningInstance()->inform(buildErrorMessage(exception));
00070 }
00071 
00072 
00073 void
00074 SUMOSAXHandler::error(const SAXParseException& exception) throw(ProcessError) {
00075     throw ProcessError(buildErrorMessage(exception));
00076 }
00077 
00078 
00079 void
00080 SUMOSAXHandler::fatalError(const SAXParseException& exception) throw(ProcessError) {
00081     throw ProcessError(buildErrorMessage(exception));
00082 }
00083 
00084 
00085 /****************************************************************************/
00086 

Generated on Wed May 5 00:06:36 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6