00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MIMOTERAEXCEPTION_HH
00024 #define MIMOTERAEXCEPTION_HH
00025
00026
00027 #include <exception>
00028 #include <string>
00029
00030 #ifndef MIMOTERA_FUNC
00031
00033
00035 #define MIMOTERA_FUNC __PRETTY_FUNCTION__
00036 #endif
00037
00039
00048 #define MIMOTERA_THROWX(exc, msg) throw ::Mimotera::InitException(exc(msg), __FILE__, __LINE__, MIMOTERA_FUNC)
00049
00051
00059 #define MIMOTERA_THROW(msg) MIMOTERA_THROWX(::Mimotera::MimoteraException, (msg))
00060
00062
00071 #define MIMOTERA_EXCEPTIONX(name, base) \
00072 class name : public base { \
00073 public: \
00074 name(const std::string & msg) \
00075 : base(msg) {} \
00076 }
00077
00079
00087 #define MIMOTERA_EXCEPTION(name) MIMOTERA_EXCEPTIONX(name, ::Mimotera::MimoteraException)
00088
00089 namespace Mimotera {
00090
00092
00119 class MimoteraException : public std::exception {
00120
00121 public:
00122
00124
00129 MimoteraException(const std::string & msg);
00130
00132 const char * what() const throw() {
00133 if (m_text.length() == 0) make_text();
00134 return m_text.c_str();
00135 }
00136
00138
00141 const MimoteraException & setLocation(const std::string & file = "",
00142 unsigned line = 0,
00143 const std::string & func = "") const;
00145 virtual ~MimoteraException() throw() { ; }
00146
00147 protected:
00149 std::string m_msg;
00150
00151 private:
00152
00154 void make_text() const;
00155
00157 mutable std::string m_text;
00158
00160 mutable std::string m_file;
00161
00163 mutable std::string m_func;
00164
00166 mutable unsigned m_line;
00167 };
00168
00170
00184 template <typename T>
00185 const T & InitException(const T & e, const std::string & file, int line = 0, const std::string func = "") {
00186 e.setLocation(file, line, func);
00187 return e;
00188 }
00189
00190
00191
00193
00199 MIMOTERA_EXCEPTION(FileException);
00200
00202
00208 MIMOTERA_EXCEPTIONX(FileNotFoundException, FileException);
00209
00211
00221 MIMOTERA_EXCEPTIONX(FileAlreadyExistingException, FileException);
00222
00224
00234 MIMOTERA_EXCEPTIONX(UnknownWritingModeException, FileException);
00235
00237
00249 MIMOTERA_EXCEPTIONX(NotRegularFileException, FileException);
00250
00252
00258 MIMOTERA_EXCEPTIONX(FileReadException, FileException);
00259
00261
00267 MIMOTERA_EXCEPTIONX(FileWriteException, FileException);
00268
00270
00281 MIMOTERA_EXCEPTIONX(WrongFileSizeException, FileException);
00282
00284
00291 MIMOTERA_EXCEPTION(EventNotReady);
00292
00294
00301 MIMOTERA_EXCEPTION(MarkerPixelException);
00302
00303 }
00304
00305 #endif
00306
00307