Global.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //---------------------------------------------------------------------------
  2. #ifndef GlobalH
  3. #define GlobalH
  4. //---------------------------------------------------------------------------
  5. #define FORMAT(S, F) Format(S, ARRAYOFCONST(F))
  6. #define FMTLOAD(I, F) FmtLoadStr(I, ARRAYOFCONST(F))
  7. #define LENOF(x) ( (sizeof((x))) / (sizeof(*(x))))
  8. #define FLAGSET(SET, FLAG) (((SET) & (FLAG)) == (FLAG))
  9. #define FLAGCLEAR(SET, FLAG) (((SET) & (FLAG)) == 0)
  10. #define FLAGMASK(ENABLE, FLAG) ((ENABLE) ? (FLAG) : 0)
  11. //---------------------------------------------------------------------------
  12. #include <System.SyncObjs.hpp>
  13. //---------------------------------------------------------------------------
  14. extern const UnicodeString EmptyString;
  15. //---------------------------------------------------------------------------
  16. UnicodeString NormalizeString(const UnicodeString & S);
  17. //---------------------------------------------------------------------------
  18. class TGuard
  19. {
  20. public:
  21. __fastcall TGuard(TCriticalSection * ACriticalSection);
  22. __fastcall ~TGuard();
  23. private:
  24. TCriticalSection * FCriticalSection;
  25. };
  26. //---------------------------------------------------------------------------
  27. class TUnguard
  28. {
  29. public:
  30. __fastcall TUnguard(TCriticalSection * ACriticalSection);
  31. __fastcall ~TUnguard();
  32. private:
  33. TCriticalSection * FCriticalSection;
  34. };
  35. //---------------------------------------------------------------------------
  36. //---------------------------------------------------------------------------
  37. #include <assert.h>
  38. #define ACCESS_VIOLATION_TEST { (*((int*)NULL)) = 0; }
  39. #if defined(_DEBUG) && !defined(DESIGN_ONLY)
  40. #define DODEBUGGING
  41. #endif
  42. #ifndef DODEBUGGING
  43. #define DebugAssert(p) ((void)0)
  44. #define DebugCheck(p) (p)
  45. #define DebugFail()
  46. #else // ifndef DODEBUGGING
  47. void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
  48. #define DebugAssert(p) ((p) ? (void)0 : DoAssert(TEXT(#p), TEXT(__FILE__), __LINE__))
  49. #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
  50. #define DebugFail() DebugAssert(false)
  51. #endif // ifndef DODEBUGGING
  52. //---------------------------------------------------------------------------
  53. #define DebugAlwaysTrue(p) (p)
  54. #define DebugAlwaysFalse(p) (p)
  55. #define DebugNotNull(p) (p)
  56. #define TraceInitPtr(p) (p)
  57. #define TraceInitStr(p) (p)
  58. #define DebugUsedParam2(p1, p2) ((&p1) == (&p2))
  59. #define DebugUsedParam(p) DebugUsedParam2(p, p)
  60. #define DebugUsedArg(p)
  61. //---------------------------------------------------------------------------
  62. #endif