Common.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //---------------------------------------------------------------------------
  2. #ifndef CommonH
  3. #define CommonH
  4. #ifndef C_ONLY
  5. //---------------------------------------------------------------------------
  6. #define CATCH(command) \
  7. try {command;} catch (Exception &E) {ShowExtendedException(&E);}
  8. #define EXCEPTION throw ExtException(NULL, "")
  9. #define SCOPY(dest, source) \
  10. strncpy(dest, source, sizeof(dest)); \
  11. dest[sizeof(dest)-1] = '\0'
  12. #define SAFE_DESTROY(OBJ) { TObject * PObj = OBJ; OBJ = NULL; delete PObj; }
  13. #define ASCOPY(dest, source) SCOPY(dest, source.c_str())
  14. #define FORMAT(S, F) Format(S, ARRAYOFCONST(F))
  15. #define FMTLOAD(I, F) FmtLoadStr(I, ARRAYOFCONST(F))
  16. #define LENOF(x) ( (sizeof((x))) / (sizeof(*(x))))
  17. //---------------------------------------------------------------------------
  18. extern const char EngShortMonthNames[12][4];
  19. //---------------------------------------------------------------------------
  20. AnsiString ReplaceChar(AnsiString Str, Char A, Char B);
  21. AnsiString DeleteChar(AnsiString Str, Char C);
  22. void PackStr(AnsiString &Str);
  23. AnsiString GetTemporaryPath();
  24. AnsiString MakeValidFileName(AnsiString FileName);
  25. AnsiString RootKeyToStr(HKEY RootKey);
  26. AnsiString BooleanToStr(bool B);
  27. AnsiString BooleanToEngStr(bool B);
  28. AnsiString CutToChar(AnsiString &Str, Char Ch, bool Trim);
  29. AnsiString ExceptionLogString(Exception *E);
  30. bool IsDots(const AnsiString Str);
  31. AnsiString __fastcall SystemTemporaryDirectory();
  32. AnsiString __fastcall StripPathQuotes(const AnsiString Path);
  33. AnsiString __fastcall AddPathQuotes(AnsiString Path);
  34. void __fastcall SplitCommand(AnsiString Command, AnsiString &Program,
  35. AnsiString & Params, AnsiString & Dir);
  36. AnsiString __fastcall FormatCommand(AnsiString Program, AnsiString Params);
  37. //---------------------------------------------------------------------------
  38. typedef void __fastcall (__closure *TProcessLocalFileEvent)
  39. (const AnsiString FileName, const TSearchRec Rec, void * Param);
  40. bool __fastcall FileSearchRec(const AnsiString FileName, TSearchRec & Rec);
  41. void __fastcall ProcessLocalDirectory(AnsiString DirName,
  42. TProcessLocalFileEvent CallBackFunc, void * Param = NULL, int FindAttrs = -1);
  43. //---------------------------------------------------------------------------
  44. #endif
  45. //---------------------------------------------------------------------------
  46. #include <assert.h>
  47. #ifndef _DEBUG
  48. #undef assert
  49. #define assert(p) ((void)0)
  50. #endif
  51. #define USEDPARAM(p) ((p) == (p))
  52. //---------------------------------------------------------------------------
  53. #endif