00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00045
00046
00047
00048
00049
00053
00054
00055
00056
00057
00058
00059
00060
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