Exception.cpp

Go to the documentation of this file.
00001 /** @file Exception.cpp
00002 * @author Gabor Madl
00003 * @date Created 02/2005
00004 * @brief The Exception class used in DREAM.
00005 *
00006 *
00007 * =================================================================
00008 * DREAM License v2.0
00009 * 
00010 * DREAM - Distributed Real-time Embedded Analysis Method
00011 * http://dre.sourceforge.net.
00012 * Copyright (c) 2005-2007 Gabor Madl, All Rights Reserved.
00013 * 
00014 * This file is part of DREAM.
00015 * 
00016 * DREAM is free software; you can redistribute it and/or modify it
00017 * under the terms of the GNU General Public License version 2 as
00018 * published by the Free Software Foundation. No future versions of
00019 * the GPL license may be automatically applied to DREAM. It is in
00020 * the sole discretion of the copyright holder to determine whether
00021 * DREAM may be released under a different license or terms. There
00022 * are no restrictions on the use of DREAM for any purpose.
00023 * 
00024 * DREAM is distributed in the hope that it will be useful,
00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00027 * GNU General Public License for more details.
00028 * 
00029 * You should have received a copy of the GNU General Public License
00030 * along with this program; if not, write to the Free Software
00031 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00032 * MA 02110-1301, USA.
00033 * 
00034 * By submitting comments, suggestions, code, code snippets,
00035 * techniques (including that of usage), and algorithms, submitters
00036 * acknowledge that they have the right to do so, that any such
00037 * submissions are given freely and unreservedly, and that they
00038 * waive any claims to copyright or ownership. In addition,
00039 * submitters acknowledge that any such submission might become
00040 * part of the copyright maintained on the overall body of code,
00041 * which comprises DREAM. By making a submission, submitter agrees
00042 * to these terms. Furthermore, submitters acknowledge that the
00043 * incorporation or modification of such submissions is entirely
00044 * at the discretion of the moderators of the DREAM project.
00045 * 
00046 * DREAM links to the Libxml2 third party library. Please see 
00047 * COPYING-libxml for the copyright information of Libxml2.
00048 * =================================================================
00049 */
00050 
00051 #include "Exception.h"
00052 
00053 namespace DREAM
00054 {
00055 
00056 Exception::Exception (const std::string& exception)
00057 : exception_ (exception)
00058 {
00059 }
00060 
00061 Exception::~Exception ()
00062 {
00063 }
00064 
00065 void Exception::handler () const
00066 {
00067         std::cerr << "Exception: " << exception_ << std::endl;
00068 }
00069 
00070 BaseClassException::BaseClassException (const std::string& exception)
00071 : Exception (exception)
00072 {
00073 }
00074 
00075 BaseClassException::~BaseClassException ()
00076 {
00077 }
00078 
00079 void BaseClassException::handler () const
00080 {
00081         std::cerr << "BaseClassException: " << exception_ << std::endl;
00082 }
00083 
00084 XMLException::XMLException (const std::string& exception)
00085 : Exception (exception)
00086 {
00087 }
00088 
00089 XMLException::~XMLException ()
00090 {
00091 }
00092 
00093 void XMLException::handler () const
00094 {
00095         std::cerr << "XMLException: " << exception_ << std::endl;
00096 }
00097 
00098 uint chartouint (const char* str)
00099         throw (DREAM::Exception)
00100 {
00101         int retval;
00102         std::string message;
00103 
00104         // Scan data
00105         if (strlen (str) > char_size)
00106         {
00107                 message << "Parameter input value \"" << str << "\" used in unsigned integer field is too long...";
00108                 throw DREAM::XMLException (message);
00109         }
00110 
00111         if (!sscanf (str, "%d", &retval))
00112         {
00113                 message << "Non-integer value \"" << str << "\" used in unsigned integer field";
00114                 throw DREAM::XMLException (message);
00115         }
00116 
00117         if (retval < 0)
00118         {
00119                 message << "Signed integer value \"" << str << "\" used in unsigned integer field";
00120                 throw DREAM::XMLException (message);
00121         }
00122 
00123         return (uint) retval;
00124 }
00125 
00126 }

Generated on Fri Jul 27 18:30:03 2007 for DREAM by  doxygen 1.5.1