00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #if !defined(_hyp_exception_h_)
00028 #define _hyp_exception_h_
00029
00030 #ifndef hyp_KERNEL_CORE_INSIDE
00031 #error Inclusion not allowed (include hyp.kernel.core.h instead)
00032 #endif
00033
00034
00035 class hyp_ker_DLL CException
00036 {
00037 protected:
00038 std::string m_Doc;
00039 static const char* ms_DefaultMessage;
00040
00041 public:
00042 CException(const char* =ms_DefaultMessage);
00043 CException(const CException&);
00044
00045 virtual std::string What(void) const;
00046 virtual std::string Type(void) const;
00047 };
00048
00049 hyp_ker_DLL std::ostream& operator<<(std::ostream&,const CException&);
00050
00051 class hyp_ker_DLL CSysException :
00052 public CException
00053 {
00054 public:
00055 CSysException(const char* =ms_DefaultMessage);
00056 virtual std::string Type(void) const;
00057 };
00058
00059
00060 #define hyp_THROW_ASSERT( Exception , Condition ) \
00061 if(!Condition) hyp_THROW2( Exception , (#Condition) );
00062
00063
00067 #define hyp_THROW( Exception ) \
00068 { \
00069 std::string doc; \
00070 hyp_STRING_BEGIN( doc ); \
00071 hyp_STRING_END( doc ); \
00072 throw Exception(doc.c_str()); \
00073 }
00074
00075
00079 #define hyp_THROW2( Exception , Args ) \
00080 { \
00081 std::string doc; \
00082 hyp_STRING_BEGIN( doc ); \
00083 hyp_STRING_DO( doc, Args ); \
00084 hyp_STRING_END( doc ); \
00085 throw Exception(doc.c_str()); \
00086 }
00087
00088
00089 class hyp_ker_DLL CComException :
00090 public CException
00091 {
00092 com_result m_Result;
00093 public:
00094 CComException(com_result= com_false,const char* =ms_DefaultMessage);
00095 CComException(const CComException&);
00096
00097 virtual std::string What(void) const;
00098 virtual std::string Type(void) const;
00099
00100 inline bool operator==(const com_result& Result) const {
00101 return (m_Result==Result);
00102 }
00103 inline bool operator!=(const com_result& Result) const {
00104 return !(*this==m_Result);
00105 }
00106 inline operator com_result() const {
00107 return GetResult();
00108 }
00109
00111 inline com_result GetResult(void) const {
00112 return m_Result;
00113 }
00114 inline bool Failed() const {
00115 return ker::Failed(m_Result);
00116 }
00117 inline bool Succeeded() const {
00118 return ker::Succeeded(m_Result);
00119 }
00120 std::string GetResultDescription(void) const;
00121 };
00122
00123
00124 #define hyp_THROW_COM_ASSERT( Condition ) \
00125 if(!Condition) hyp_THROW_COM2( hyp_ker::com_assertion_failed, (#Condition) );
00126
00127
00131 #define hyp_THROW_COM2( Result , Args ) \
00132 { \
00133 std::string doc; \
00134 hyp_STRING_BEGIN( doc ); \
00135 hyp_STRING_DO( doc , Args ); \
00136 hyp_STRING_END( doc ); \
00137 throw hyp::ker::CComException(Result,doc.c_str()); \
00138 }
00139
00143 #define hyp_THROW_COM( Result ) \
00144 { \
00145 std::string doc; \
00146 hyp_STRING_BEGIN( doc ); \
00147 hyp_STRING_END( doc ); \
00148 throw hyp::ker::CComException(Result,doc.c_str()); \
00149 }
00150
00151 #define hyp_CATCH_COM_ITOR \
00152 catch(hyp::ker::CComException& Except) { \
00153 if( Except.Failed() ) throw Except; \
00154 }
00155
00156 #endif