Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.9 KiB

  1. /*
  2. ****************************************************************************
  3. | Copyright (C) 2002 Microsoft Corporation
  4. |
  5. | Component / Subcomponent
  6. | IIS 6.0 / IIS Migration Wizard
  7. |
  8. | Based on:
  9. | http://iis6/Specs/IIS%20Migration6.0_Final.doc
  10. |
  11. | Abstract:
  12. | Utility macros
  13. |
  14. | Author:
  15. | ivelinj
  16. |
  17. | Revision History:
  18. | V1.00 March 2002
  19. |
  20. ****************************************************************************
  21. */
  22. #pragma once
  23. // DEBUG Macros
  24. #ifndef VERIFY
  25. #ifdef _DEBUG
  26. #define VERIFY( t ) _ASSERT( (t) )
  27. #else
  28. #define VERIFY( t ) (t)
  29. #endif // _DEBUG
  30. #endif // VERIFY
  31. // General
  32. #define ARRAY_SIZE( t ) ( sizeof( t ) / sizeof( t[ 0 ] ) )
  33. // Exception helpers
  34. ///////////////////////////////////////////////////////////////////////////////////////
  35. // If the boolean expression 't' evaluates to FALSE/false - 'exc' is thrown
  36. #define IF_FAILED_BOOL_THROW( t, exc ) if ( !(t) ){ throw (exc); }else{}
  37. // If the expression evaluates to FAILED( hr ), then exc is thrown
  38. #define IF_FAILED_HR_THROW( t, exc ) \
  39. {\
  40. HRESULT _hr = (t);\
  41. if ( FAILED( _hr ) )\
  42. {\
  43. if ( ( _hr != E_FAIL ) || ( ::GetLastError() == ERROR_SUCCESS ) ) ::SetLastError( _hr );\
  44. throw (exc);\
  45. }\
  46. }
  47. // Used at the last point where excpetions should be catched and handled
  48. // Requires hr variable to be already defined
  49. #define BEGIN_EXCEP_TO_HR try
  50. #define END_EXCEP_TO_HR \
  51. catch( const CBaseException& err )\
  52. {\
  53. CTools::SetErrorInfo( err.GetDescription() );\
  54. hr = E_FAIL;\
  55. }\
  56. catch( CCancelException& )\
  57. {\
  58. hr = S_FALSE;\
  59. }\
  60. catch( const _com_error& err )\
  61. {\
  62. _ASSERT( err.Error() == E_OUTOFMEMORY );\
  63. err;\
  64. hr = E_OUTOFMEMORY;\
  65. }\
  66. catch( std::bad_alloc& )\
  67. {\
  68. hr = E_OUTOFMEMORY;\
  69. }