InMemoryBuffer.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "Reader.h"
  3. #include "ReferenceCounter.h"
  4. #include "Writer.h"
  5. namespace Framework
  6. {
  7. class InMemoryBuffer : public Reader,
  8. public Writer,
  9. public virtual ReferenceCounter
  10. {
  11. private:
  12. char** buffer;
  13. int readPos;
  14. int writePos;
  15. int numBuffers;
  16. int maxWritePos;
  17. public:
  18. DLLEXPORT InMemoryBuffer();
  19. DLLEXPORT ~InMemoryBuffer();
  20. //! Reads from the resource
  21. //! \param bytes An array to be filled with bytes from the resource
  22. //! \param len How many bytes should be read from the resource
  23. DLLEXPORT void lese(char* bytes, int len) override;
  24. //! Writes to the resource
  25. //! \param bytes An array containing the bytes to be written to the
  26. //! resource
  27. //! \param len How many bytes should be written to the resource
  28. DLLEXPORT void schreibe(const char* bytes, int len) override;
  29. //! Reads the next line of the resource
  30. //! \return The read line as Text with line break
  31. DLLEXPORT Text* leseZeile() override;
  32. //! Checks whether the resource has been fully read
  33. //! return 1 if the resource has been fully read. 0 otherwise
  34. DLLEXPORT bool istEnde() const override;
  35. //! Sets the position of the byte to be read next
  36. //! \param pos The index of the byte
  37. //! \param ende 1 if the index counts from the end of the resource. 0 if
  38. //! the index counts from the beginning of the resource
  39. DLLEXPORT void setLPosition(__int64 pos, bool ende) override;
  40. //! Sets the position of the byte to be written next
  41. //! \param pos The index of the byte
  42. //! \param ende 1 if the index counts from the end of the resource. 0 if
  43. //! the index counts from the beginning of the resource
  44. DLLEXPORT void setSPosition(__int64 pos, bool ende) override;
  45. //! Returns the index of the byte from the resource that would be read next
  46. //! return -1 if an error occurred. Otherwise the position of the read pointer
  47. DLLEXPORT __int64 getLPosition() const override;
  48. //! Returns the index of the byte from the resource that would be written next
  49. //! return -1 if an error occurred. Otherwise the position of the write pointer
  50. DLLEXPORT __int64 getSPosition() const override;
  51. //! Returns the number of bytes to be read
  52. DLLEXPORT __int64 getSize() const override;
  53. };
  54. } // namespace Framework