00001 #ifndef _FV_EXCEPTION_H_ 00002 #define _FV_EXCEPTION_H_ 00003 00004 #include<stdexcept> 00005 #include<string> 00006 #include<ostream> 00007 00008 00009 //namespace FemViewer 00010 //{ 00011 class fv_exception : std::exception 00012 { 00013 00014 public: 00015 00016 fv_exception(): sReason("Unknown exception") {} 00017 fv_exception(const char* resson) : sReason(resson) {} 00018 00019 fv_exception(const std::string& reason) 00020 : sReason(reason) 00021 {} 00022 00023 fv_exception(const fv_exception& excpt) 00024 : sReason(excpt.sReason) 00025 {} 00026 00027 fv_exception& operator =(const fv_exception& excpt) 00028 { 00029 if(this != &excpt) 00030 sReason = excpt.sReason; 00031 return *this; 00032 } 00033 00034 virtual ~fv_exception() throw() {} 00035 00036 virtual const char* what() const throw() { return sReason.c_str(); } 00037 00038 protected: 00039 00040 std::string sReason; 00041 00042 friend std::ostream& operator <<(std::ostream &lhs, const fv_exception& excpt); 00043 }; 00044 00045 inline std::ostream& operator <<(std::ostream &lhs, const fv_exception &rhs) 00046 { 00047 return lhs << rhs.sReason; 00048 } 00049 //} 00050 00051 #endif /* _FV_EXCEPTION_H_ 00052 */
1.6.1