error_fwd.h

Go to the documentation of this file.
00001 00004 /* 00005 * Copyright © 2000, 2001 Sofus Mortensen 00006 * 00007 * This material is provided "as is", with absolutely no warranty 00008 * expressed or implied. Any use is at your own risk. Permission to 00009 * use or copy this software for any purpose is hereby granted without 00010 * fee, provided the above notices are retained on all copies. 00011 * Permission to modify the code and to distribute modified code is 00012 * granted, provided the above notices are retained, and a notice that 00013 * the code was modified is included with the above copyright notice. 00014 * 00015 * This header is part of comet. 00016 * http://www.lambdasoft.dk/comet 00017 */ 00018 00019 #ifndef COMET_ERROR_FWD_H 00020 #define COMET_ERROR_FWD_H 00021 00022 #include <comet/config.h> 00023 00024 #include <stdexcept> 00025 #include <wtypes.h> 00026 00027 #pragma warning(push) 00028 #pragma warning(disable : 4290) 00029 00030 namespace comet { 00031 template<typename Itf> class com_ptr; 00032 class bstr_t; 00033 00034 class com_error; 00038 namespace impl { 00039 class raise_exception_t 00040 { 00041 public: 00042 // Raising a std::exception 00043 // inline void operator()(const std::exception& err) const; 00044 00045 // Raising an HRESULT with a message 00046 inline void operator()(const bstr_t& msg, HRESULT hr = E_FAIL) const; 00047 00048 // Raising an HRESULT 00049 inline void operator()(HRESULT hr) const; 00050 }; 00051 00052 } 00053 00055 00071 static impl::raise_exception_t raise_exception; 00072 00074 00079 inline HRESULT operator|(HRESULT hr, const impl::raise_exception_t&) 00080 {if (FAILED(hr)) raise_exception(hr); return hr; } 00081 00102 template<bool OVERRIDE> 00103 struct throw_error_handler 00104 { 00106 static inline void throw_error(HRESULT hr, const com_ptr<IErrorInfo> &ei); 00107 }; 00109 } 00110 00111 #pragma warning(pop) 00112 00113 #endif