Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

boss_exceptions.h

Go to the documentation of this file.
00001 /* boss_exceptions.h    $Revision: 1.4 $ $Date: 2005/12/10 20:33:54 $
00002    Copyright (C) 1999 University of Bonn.
00003    http://www.ikp.uni-bonn.de/boss
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA  02111-1307, USA.
00019 */
00020 
00028 #ifndef __BOSS_EXCEPTIONSH__
00029 #define __BOSS_EXCEPTIONSH__
00030 
00031 using namespace std;
00032 
00033 #include <string>
00034 #include <stdexcept>
00035 #include <iostream>
00036 
00037 #define ERROR_ON false
00038 
00039 namespace BOSS{
00040 
00044 /*class ModuleException : public logic_error {
00045   public:
00046     ModuleException(string message): logic_error(message) {}
00047   };
00048 
00049 */
00053 /*class UnknownLanguageException : public logic_error {
00054     string reason;
00055   public:
00056     UnknownLanguageType(string lang) {
00057       reason = "Cannot create language dependent component of type \"" + lang + "\"";
00058     }
00059     const char *what() const { 
00060       return reason.c_str(); 
00061     }
00062   };
00063 */
00064 
00065 
00066 struct FileOpenError {
00067   string name;
00068   string inf;
00069   FileOpenError(const string & N, const string & I, const bool f = ERROR_ON) : 
00070     name(N), inf(I) { if(f) printError(false); }
00071   void printError(const bool & fatal = false) const
00072     {
00073       if(fatal) {
00074         cerr << name << " : Fatal: Can't open file: " << inf << endl; exit(-1);
00075       }
00076       else {
00077         cerr << name << " : Can't open file: " << inf << ". Ignoring file!" << endl;
00078       }
00079     }
00080 };
00081 
00082 struct FileFormatError {
00083   string   name;
00084   string   inf;
00085   unsigned line;
00086   FileFormatError(const string & N, const string & I, const unsigned & L, const bool f = ERROR_ON) :
00087     name(N), inf(I), line(L) { if(f) printError(false); }
00088   void printError(const bool & fatal = false) const
00089     {
00090       if(fatal) {
00091         cerr << name << " : Fatal: Format error in file: " << inf << " at line " << line << endl; exit(-1);
00092       }
00093       else {
00094         cerr << name << " : Format error in file: " << inf << " at line " << line << ". Ignoring rest of file!" << endl;
00095       }
00096     }
00097 };
00098 
00099 struct StringFormatError {
00100   string name;
00101   string inf;
00102   StringFormatError(const string & N, const string & I, const bool f = ERROR_ON) : 
00103     name(N), inf(I) { if(f) printError(false); }
00104   void printError(const bool & fatal = false) const
00105     {
00106       if(fatal) {
00107         cerr << name << " : Fatal: Wrong string format: " << inf << endl; exit(-1);
00108       }
00109       else {
00110         cerr << name << " : Wrong string format: " << inf << ". No modifications made!" << endl;
00111       }
00112     }
00113 };
00114 
00115 struct ItemNotFound {
00116   string name;
00117   string inf;
00118   ItemNotFound(const string & N, const string & I, const bool f = ERROR_ON) : name(N), inf(I)
00119     { if(f) printError(false); }
00120   void printError(const bool & fatal = false) const
00121     {
00122       if(fatal) {
00123         cerr << name << " : Fatal: Item: " << inf << " not present" << endl; exit(-1);
00124       }
00125       else {
00126         cerr << name << " : Item: " << inf << " not present. Ignoring item!" << endl;
00127       }
00128     }
00129 };
00130  
00131 struct KeyNotFound {
00132   string name;
00133   unsigned inf;
00134   KeyNotFound(const string & N, const unsigned & I, const bool f = ERROR_ON) : name(N), inf(I)
00135     { if(f) printError(false); }
00136   void printError(const bool & fatal = false) const
00137     {
00138       if(fatal) {
00139         cerr << name << " : Fatal: Key: " << inf << " not present" << endl; exit(-1);
00140       }
00141       else {
00142         cerr << name << " : Key: " << inf << " not present. Ignoring key!" << endl;
00143       }
00144     }
00145 };
00146 }
00147 
00148 #undef ERROR_ON
00149 
00150 #endif
00151 
00152   

Generated on Tue Dec 20 23:14:37 2005 for BOSS by doxygen 1.3.6