Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

std_except.hh

Go to the documentation of this file.
00001 #ifndef _STD_EXCEPT_HH_
00002 #define _STD_EXCEPT_HH_
00003 
00004 #include <exception>
00005 #include <string>
00006 
00007 using namespace std;
00008 
00009 void handle_exception(const exception&);
00010 
00011 class StandardException : public exception {
00012 public:
00013   StandardException(const string& fname = string(), int ln = 0, 
00014                     const string& msg = string())
00015     { MakeMessage(fname,ln,msg); BuildBacktrace(); }
00016   virtual ~StandardException() {}
00017   virtual const char *what() const { return message.c_str(); };
00018 protected:
00019   string message;
00020   string bt;
00021 
00022   void MakeMessage(const string& file, int line, const string& msg);
00023   void BuildBacktrace();
00024 };
00025 
00026 //void ThrowException(const exception&);
00027 
00028 class StandardMemoryExhaustException : public StandardException {
00029 public:
00030   StandardMemoryExhaustException() : StandardException() {};
00031   StandardMemoryExhaustException(const string& fname, int ln, 
00032                                  const string& msg = string())
00033     : StandardException(fname, ln, head()+msg) {}
00034   const char *head() const {
00035     return "Cannot allocate memory:  Memory full.\n";};
00036 };
00037 
00038 class StandardDivisionByZeroException : public StandardException {
00039 public:
00040   StandardDivisionByZeroException() : StandardException() {};
00041   StandardDivisionByZeroException(const string& fname, int ln,
00042                                   const string& msg = string())
00043     : StandardException(fname, ln, head()+msg) {}
00044   const char *head() const {return "Division by zero.\n";};
00045 };
00046 
00047 #endif

Generated on Wed Jun 18 09:16:21 2003 for admc++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002