FileBuffer.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //---------------------------------------------------------------------------
  2. #ifndef FileBufferH
  3. #define FileBufferH
  4. #include <classes.hpp>
  5. //---------------------------------------------------------------------------
  6. enum TEOLType { eolLF /* \n */, eolCRLF /* \r\n */, eolCR /* \r */ };
  7. const int cpRemoveCtrlZ = 0x01;
  8. //---------------------------------------------------------------------------
  9. class TFileBuffer
  10. {
  11. public:
  12. __fastcall TFileBuffer();
  13. virtual __fastcall ~TFileBuffer();
  14. void __fastcall Convert(char * Source, char * Dest, int Params);
  15. void __fastcall Convert(TEOLType Source, TEOLType Dest, int Params);
  16. void __fastcall Convert(char * Source, TEOLType Dest, int Params);
  17. void __fastcall Convert(TEOLType Source, char * Dest, int Params);
  18. void __fastcall Insert(int Index, const char * Buf, int Len);
  19. void __fastcall Delete(int Index, int Len);
  20. DWORD __fastcall LoadStream(TStream * Stream, const DWORD Len, bool ForceLen);
  21. DWORD __fastcall ReadStream(TStream * Stream, const DWORD Len, bool ForceLen);
  22. void __fastcall WriteToStream(TStream * Stream, const DWORD Len);
  23. __property TMemoryStream * Memory = { read=FMemory, write=SetMemory };
  24. __property char * Data = { read=GetData };
  25. __property int Size = { read=FSize, write=SetSize };
  26. __property int Position = { read=GetPosition, write=SetPosition };
  27. private:
  28. TMemoryStream * FMemory;
  29. int FSize;
  30. void __fastcall SetMemory(TMemoryStream * value);
  31. char * __fastcall GetData() const { return (char *)FMemory->Memory; }
  32. void __fastcall SetSize(int value);
  33. void __fastcall SetPosition(int value);
  34. int __fastcall GetPosition() const;
  35. };
  36. //---------------------------------------------------------------------------
  37. class TSafeHandleStream : public THandleStream
  38. {
  39. public:
  40. __fastcall TSafeHandleStream(int AHandle);
  41. virtual int __fastcall Read(void * Buffer, int Count);
  42. virtual int __fastcall Write(const void * Buffer, int Count);
  43. };
  44. //---------------------------------------------------------------------------
  45. char * __fastcall EOLToStr(TEOLType EOLType);
  46. //---------------------------------------------------------------------------
  47. #endif