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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef COMSTL_INCL_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS
00048 #define COMSTL_INCL_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define COMSTL_VER_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS_MAJOR 4
00052 # define COMSTL_VER_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS_MINOR 2
00053 # define COMSTL_VER_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS_REVISION 4
00054 # define COMSTL_VER_COMSTL_ERROR_H_ERRORINFO_FUNCTIONS_EDIT 43
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef COMSTL_INCL_COMSTL_H_COMSTL
00062 # include <comstl/comstl.h>
00063 #endif
00064 #ifndef STLSOFT_INCL_H_OLEAUTO
00065 # define STLSOFT_INCL_H_OLEAUTO
00066 # include <oleauto.h>
00067 #endif
00068 #ifndef STLSOFT_INCL_H_OAIDL
00069 # define STLSOFT_INCL_H_OAIDL
00070 # include <oaidl.h>
00071 #endif
00072
00073 #ifdef STLSOFT_UNITTEST
00074 # include <wchar.h>
00075 #endif
00076
00077
00078
00079
00080
00081 #if !defined(_COMSTL_NO_NAMESPACE) && \
00082 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00083 # if defined(_STLSOFT_NO_NAMESPACE)
00084
00085 namespace comstl
00086 {
00087 # else
00088
00089
00090 namespace stlsoft
00091 {
00092
00093 namespace comstl_project
00094 {
00095
00096 # endif
00097 #endif
00098
00099
00100
00101
00102
00103 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00104
00105 STLSOFT_INLINE HRESULT comstl__set_error_info_w_( cs_char_w_t const* description
00106 , cs_char_w_t const* source
00107 , GUID const* guid
00108 , cs_char_w_t const* helpFile
00109 , cs_dword_t const* helpContext)
00110 {
00111 ICreateErrorInfo *pCEI;
00112 HRESULT hr;
00113
00114 hr = STLSOFT_NS_GLOBAL(CreateErrorInfo)(&pCEI);
00115
00116 if(SUCCEEDED(hr))
00117 {
00118 IErrorInfo *pEI;
00119
00120
00121 hr = COMSTL_ITF_CALL(pCEI)->QueryInterface( COMSTL_ITF_THIS(pCEI)
00122 COMSTL_IID_2_REF(IID_IErrorInfo)
00123 , stlsoft_reinterpret_cast(void**, &pEI));
00124
00125 if(SUCCEEDED(hr))
00126 {
00127 if(NULL != description)
00128 {
00129 hr = COMSTL_ITF_CALL(pCEI)->SetDescription(COMSTL_ITF_THIS(pCEI) stlsoft_const_cast(LPOLESTR, description));
00130 }
00131
00132 if(NULL != source)
00133 {
00134 hr = COMSTL_ITF_CALL(pCEI)->SetSource(COMSTL_ITF_THIS(pCEI) stlsoft_const_cast(LPOLESTR, source));
00135 }
00136
00137 if(NULL != guid)
00138 {
00139 hr = COMSTL_ITF_CALL(pCEI)->SetGUID(COMSTL_ITF_THIS(pCEI) COMSTL_IID_2_REF(*guid));
00140 }
00141
00142 if(NULL != helpFile)
00143 {
00144 hr = COMSTL_ITF_CALL(pCEI)->SetHelpFile(COMSTL_ITF_THIS(pCEI) stlsoft_const_cast(LPOLESTR, helpFile));
00145 }
00146
00147 if(NULL != helpContext)
00148 {
00149 hr = COMSTL_ITF_CALL(pCEI)->SetHelpContext(COMSTL_ITF_THIS(pCEI) *helpContext);
00150 }
00151
00152 if(SUCCEEDED(hr))
00153 {
00154 hr = STLSOFT_NS_GLOBAL(SetErrorInfo)(0, pEI);
00155 }
00156
00157 COMSTL_ITF_CALL(pEI)->Release(COMSTL_ITF_THIS0(pEI));
00158 }
00159
00160 COMSTL_ITF_CALL(pCEI)->Release(COMSTL_ITF_THIS0(pCEI));
00161 }
00162
00163 return hr;
00164 }
00165
00166 STLSOFT_INLINE HRESULT comstl__set_error_info_a_helper_(cs_char_a_t const* s_a, cs_char_w_t **ps_w)
00167 {
00168 COMSTL_ASSERT(NULL != ps_w);
00169
00170 if(NULL == s_a)
00171 {
00172 return S_FALSE;
00173 }
00174 else
00175 {
00176 const cs_size_t len = STLSOFT_NS_GLOBAL(strlen)(s_a);
00177
00178 if(NULL == (*ps_w = stlsoft_static_cast(cs_char_w_t*, STLSOFT_NS_GLOBAL(CoTaskMemAlloc)((1 + len) * sizeof(cs_char_w_t)))))
00179 {
00180 return E_OUTOFMEMORY;
00181 }
00182 else
00183 {
00184 int n = STLSOFT_NS_GLOBAL(MultiByteToWideChar)(0, 0, s_a, -1, *ps_w, stlsoft_static_cast(int, 1 + len));
00185
00186 if(0 == n)
00187 {
00188 return HRESULT_FROM_WIN32(STLSOFT_NS_GLOBAL(GetLastError)());
00189 }
00190 else
00191 {
00192 if(stlsoft_static_cast(cs_size_t, n) < len)
00193 {
00194 (*ps_w)[n] = L'\0';
00195 }
00196 }
00197 }
00198
00199 return S_OK;
00200 }
00201 }
00202
00203 STLSOFT_INLINE HRESULT comstl__set_error_info_a_( cs_char_a_t const* description
00204 , cs_char_a_t const* source
00205 , GUID const* guid
00206 , cs_char_a_t const* helpFile
00207 , cs_dword_t const* helpContext)
00208 {
00209 HRESULT hr = S_OK;
00210 cs_char_w_t *description_w = NULL;
00211 cs_char_w_t *source_w = NULL;
00212 cs_char_w_t *helpFile_w = NULL;
00213
00214 if(SUCCEEDED(hr))
00215 {
00216 hr = comstl__set_error_info_a_helper_(description, &description_w);
00217 }
00218 if(SUCCEEDED(hr))
00219 {
00220 hr = comstl__set_error_info_a_helper_(source, &source_w);
00221 }
00222 if(SUCCEEDED(hr))
00223 {
00224 hr = comstl__set_error_info_a_helper_(helpFile, &helpFile_w);
00225 }
00226
00227 if(SUCCEEDED(hr))
00228 {
00229 hr = comstl__set_error_info_w_(description_w, source_w, guid, helpFile_w, helpContext);
00230 }
00231
00232 STLSOFT_NS_GLOBAL(CoTaskMemFree)(description_w);
00233 STLSOFT_NS_GLOBAL(CoTaskMemFree)(source_w);
00234 STLSOFT_NS_GLOBAL(CoTaskMemFree)(helpFile_w);
00235
00236 return hr;
00237 }
00238
00239 #endif
00240
00247 STLSOFT_INLINE HRESULT comstl__set_error_info_description_w(cs_char_w_t const* description)
00248 {
00249 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00250
00251 return comstl__set_error_info_w_(description, NULL, NULL, NULL, NULL);
00252 }
00253
00260 STLSOFT_INLINE HRESULT comstl__set_error_info_description_a(cs_char_a_t const* description)
00261 {
00262 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00263
00264 return comstl__set_error_info_a_(description, NULL, NULL, NULL, NULL);
00265 }
00266
00273 STLSOFT_INLINE HRESULT comstl__set_error_info_description_and_source_w(cs_char_w_t const* description, cs_char_w_t const* source)
00274 {
00275 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00276 COMSTL_MESSAGE_ASSERT("error info source string cannot be NULL", NULL != source);
00277
00278 return comstl__set_error_info_w_(description, source, NULL, NULL, NULL);
00279 }
00280
00287 STLSOFT_INLINE HRESULT comstl__set_error_info_description_and_source_a(cs_char_a_t const* description, cs_char_a_t const* source)
00288 {
00289 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00290 COMSTL_MESSAGE_ASSERT("error info source string cannot be NULL", NULL != source);
00291
00292 return comstl__set_error_info_a_(description, source, NULL, NULL, NULL);
00293 }
00294
00301 STLSOFT_INLINE HRESULT comstl__set_error_info_w(cs_char_w_t const* description
00302 , cs_char_w_t const* source
00303 , REFGUID guid
00304 , cs_char_w_t const* helpFile
00305 , cs_dword_t helpContext)
00306 {
00307 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00308 COMSTL_MESSAGE_ASSERT("error info source string cannot be NULL", NULL != source);
00309 COMSTL_MESSAGE_ASSERT("error info help file string cannot be NULL", NULL != helpFile);
00310
00311 return comstl__set_error_info_w_(description, source, COMSTL_REF_2_PTR(guid), helpFile, &helpContext);
00312 }
00313
00320 STLSOFT_INLINE HRESULT comstl__set_error_info_a(cs_char_a_t const* description
00321 , cs_char_a_t const* source
00322 , REFGUID guid
00323 , cs_char_a_t const* helpFile
00324 , cs_dword_t helpContext)
00325 {
00326 COMSTL_MESSAGE_ASSERT("error info description string cannot be NULL", NULL != description);
00327 COMSTL_MESSAGE_ASSERT("error info source string cannot be NULL", NULL != source);
00328 COMSTL_MESSAGE_ASSERT("error info help file string cannot be NULL", NULL != helpFile);
00329
00330 return comstl__set_error_info_a_(description, source, COMSTL_REF_2_PTR(guid), helpFile, &helpContext);
00331 }
00332
00333
00334
00335
00336
00337 #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
00338 namespace comstl
00339 {
00340 #endif
00341
00342
00343
00344
00345
00346 #ifdef __cplusplus
00347
00352 inline HRESULT set_error_info(cs_char_a_t const* description)
00353 {
00354 return comstl__set_error_info_description_a(description);
00355 }
00356
00363 inline HRESULT set_error_info(cs_char_w_t const* description)
00364 {
00365 return comstl__set_error_info_description_w(description);
00366 }
00367
00375 inline HRESULT set_error_info(cs_char_a_t const* description, cs_char_a_t const* source)
00376 {
00377 return comstl__set_error_info_description_and_source_a(description, source);
00378 }
00379
00387 inline HRESULT set_error_info(cs_char_w_t const* description, cs_char_w_t const* source)
00388 {
00389 return comstl__set_error_info_description_and_source_w(description, source);
00390 }
00391
00400 inline HRESULT set_error_info(cs_char_a_t const* description, cs_char_a_t const* source, REFGUID guid)
00401 {
00402 return comstl__set_error_info_a_(description, source, &guid, NULL, NULL);
00403 }
00404
00413 inline HRESULT set_error_info(cs_char_w_t const* description, cs_char_w_t const* source, REFGUID guid)
00414 {
00415 return comstl__set_error_info_w_(description, source, &guid, NULL, NULL);
00416 }
00417
00418 #endif
00419
00420
00421
00422
00423
00424 #ifdef STLSOFT_UNITTEST
00425 # include "./unittest/errorinfo_functions_unittest_.h"
00426 #endif
00427
00428
00429
00430 #ifndef _COMSTL_NO_NAMESPACE
00431 # if defined(_STLSOFT_NO_NAMESPACE) || \
00432 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00433 }
00434 # else
00435 }
00436 }
00437 # endif
00438 #endif
00439
00440
00441
00442 #endif
00443
00444