Source code of Windows XP (NT5)
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.

136 lines
3.1 KiB

  1. //-----------------------------------------------------------------------
  2. // defines.h
  3. //
  4. // Author: Kishnan Nedungadi
  5. //-----------------------------------------------------------------------
  6. #ifndef __DEFINES_H
  7. #define __DEFINES_H
  8. #include <vector>
  9. #include <list>
  10. typedef std::vector<double> arrayDouble;
  11. typedef std::vector<double>::iterator arrayDoubleIter;
  12. typedef std::list<double> listDouble;
  13. typedef std::list<double>::iterator listDoubleIter;
  14. #define SZ_MAX_SIZE 256
  15. #define MAX_LIST_ITEMS 100000
  16. #define NTDM_BEGIN_METHOD() try {\
  17. hr = NOERROR;
  18. #define NTDM_END_METHOD() }\
  19. catch(...)\
  20. {\
  21. hr = E_UNEXPECTED;\
  22. goto error;\
  23. }\
  24. error:;
  25. #define NTDM_ERR_IF_FAIL(stmt) if FAILED(hr = stmt)\
  26. {\
  27. CNTDMUtils::ErrorHandler(NULL, hr, FALSE);\
  28. ;\
  29. goto error;\
  30. }
  31. #define NTDM_ERR_MSG_IF_FAIL(stmt) if FAILED(hr = stmt)\
  32. {\
  33. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  34. ;\
  35. goto error;\
  36. }
  37. #define NTDM_Hr(hrCode) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, hrCode)
  38. #define NTDM_EXIT(hrVal) {\
  39. hr = hrVal;\
  40. CNTDMUtils::ErrorHandler(NULL, hr, FALSE);\
  41. goto error;\
  42. }
  43. #define NTDM_ERR_GETLASTERROR_IF_NULL(stmt) if(NULL == stmt)\
  44. {\
  45. hr = NTDM_Hr(GetLastError());\
  46. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  47. goto error;\
  48. }
  49. #define NTDM_ERR_GETLASTERROR_IF_FALSE(stmt) if(FALSE == stmt)\
  50. {\
  51. hr = NTDM_Hr(GetLastError());\
  52. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  53. goto error;\
  54. }
  55. #define NTDM_ERR_IF_NULL(stmt) if(NULL == stmt)\
  56. {\
  57. hr = E_FAIL;\
  58. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  59. goto error;\
  60. }
  61. #define NTDM_ERR_IF_MINUSONE(stmt) if(-1 == stmt)\
  62. {\
  63. hr = E_FAIL;\
  64. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  65. goto error;\
  66. }
  67. #define NTDM_ERRID_IF_NULL(stmt, err) if(NULL == stmt)\
  68. {\
  69. hr = err;\
  70. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  71. goto error;\
  72. }
  73. #define NTDM_ERR_IF_FALSE(stmt) if(!stmt)\
  74. {\
  75. hr = E_FAIL;\
  76. CNTDMUtils::ErrorHandler(m_hWnd, hr);\
  77. goto error;\
  78. }
  79. #define NTDM_DELETE_OBJECT(object) if(object)\
  80. {\
  81. delete object;\
  82. object = NULL;\
  83. }
  84. #define NTDM_RELEASE_IF_NOT_NULL(object) if(object)\
  85. {\
  86. object->Release();\
  87. }
  88. #define NTDM_CHECK_CB_ERR(stmt) {\
  89. long ntdm_idx = stmt;\
  90. if(CB_ERR == ntdm_idx)\
  91. {\
  92. NTDM_EXIT(E_FAIL);\
  93. }\
  94. else if(CB_ERRSPACE == ntdm_idx)\
  95. {\
  96. NTDM_EXIT(E_OUTOFMEMORY);\
  97. }\
  98. }\
  99. #define NTDM_FREE_BSTR(bstr)if(bstr)\
  100. {\
  101. SysFreeString(bstr);\
  102. bstr = NULL;\
  103. }
  104. #define RGB_WHITE 0xffffff
  105. #define RGB_BLACK 0x0
  106. #define RGB_GLASS 0x8a8a8a
  107. #define RGB_RED 0xff
  108. #define RGB_BLUE 0xff0000
  109. #define NOTEMPTY_BSTR_VARIANT(pvValue) (V_VT(pvValue)==VT_BSTR && V_BSTR(pvValue) && wcslen(V_BSTR(pvValue)))
  110. #endif //__DEFINES_H