Global.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 DebugAssert(p) ((void)0)
  41. #define DebugCheck(p) (p)
  42. #define DebugFail()
  43. #else // if !defined(_DEBUG) || defined(DESIGN_ONLY)
  44. void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
  45. #define DebugAssert(p) ((p) ? (void)0 : DoAssert(TEXT(#p), TEXT(__FILE__), __LINE__))
  46. #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
  47. #define DebugFail() DebugAssert(false)
  48. #endif // if !defined(_DEBUG) || defined(DESIGN_ONLY)
  49. //---------------------------------------------------------------------------
  50. #define DebugAlwaysTrue(p) (p)
  51. #define DebugAlwaysFalse(p) (p)
  52. #define DebugNotNull(p) (p)
  53. #define TraceInitPtr(p) (p)
  54. #define TraceInitStr(p) (p)
  55. #define DebugUsedParam(p) ((&p) == (&p))
  56. #define DebugUsedArg(p)
  57. //---------------------------------------------------------------------------
  58. #endif