Exception.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FortTk_Exception_H
00021 #define FortTk_Exception_H
00022
00023
00024
00025 #include <iostream>
00026 #include <sstream>
00027 #include <string>
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 namespace fortTkSupport {
00042
00043 class BaseException {
00044 public:
00045 BaseException() { }
00046 virtual ~BaseException() { }
00047
00048 virtual const std::string& GetMessage() const = 0;
00049 virtual void Report(std::ostream& os) const = 0;
00050 virtual void Report() const = 0;
00051 };
00052
00053
00054 class Exception : public BaseException {
00055 public:
00056 Exception(const char* m,
00057 const char* filenm = NULL, unsigned int lineno = 0);
00058 Exception(std::string m,
00059 const char* filenm = NULL, unsigned int lineno = 0);
00060 virtual ~Exception();
00061
00062 virtual const std::string& GetMessage() const { return msg; }
00063 virtual void Report(std::ostream& os) const {
00064 os << "OpenADFortTk::Exception: " << msg << std::endl;
00065 }
00066 virtual void Report() const { Report(std::cerr); }
00067
00068 private:
00069 void Ctor(std::string& m,
00070 const char* filenm = NULL, unsigned int lineno = 0);
00071
00072 std::string msg;
00073 };
00074
00075
00076 class FatalException : public Exception {
00077 public:
00078 FatalException(const char* m,
00079 const char* filenm = NULL, unsigned int lineno = 0);
00080 FatalException(std::string m,
00081 const char* filenm = NULL, unsigned int lineno = 0);
00082 virtual ~FatalException();
00083
00084 virtual void Report(std::ostream& os) const {
00085 os << "OpenADFortTk::FatalException: " << GetMessage() << std::endl;
00086 }
00087 virtual void Report() const { Report(std::cerr); }
00088
00089 };
00090
00091 }
00092
00093
00094
00095 #endif // FortTk_Exception_H