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

/home/rdbrown/doxygen/cse125g1/src/include/exception.h

00001 #ifndef MM_EXCEPTION_H
00002 #define  MM_EXCEPTION_H
00003 
00004 #include <iostream>
00005 using std::ostream;
00006 
00007 class Exception {
00008     int lineno;
00009     const char *function;
00010     const char *filename;
00011         const char *msg;
00012 public:
00013     Exception(const char *func, const char *file, int line)
00014         : lineno(line), function(func), filename(file) { }
00015     Exception(const char *m, const char *func, const char *file, int line)
00016           : lineno(line), function(func), filename(file), msg(m) { }
00017     
00018     virtual const char *getMessage(void) const { return msg; }
00019     const char * getFunctionName(void) const {
00020         return function;
00021     }
00022     int getLineNumber(void) const {
00023         return lineno;
00024     }
00025     const char *getFileName(void) const {
00026         return filename;
00027     }
00028 };
00029 
00030 inline ostream& operator<<(ostream& os, Exception& ex) {
00031   return os << ex.getFunctionName() << " ( " << ex.getFileName() 
00032                         << " line " << ex.getLineNumber() << " ): " << ex.getMessage()
00033                         << "\n";
00034 }
00035 
00036 #define EXCEPTION_ARGS __FUNCTION__, __FILE__, __LINE__
00037 #define THROW(type, msg) throw type(msg, EXCEPTION_ARGS)
00038 
00039 #endif /* MM_EXCEPTION_H */

Generated on Thu Aug 18 16:03:09 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18