Writer.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include <iostream>
  3. #include "OperatingSystem.h"
  4. namespace Framework
  5. {
  6. class Text;
  7. class StreamWriter
  8. {
  9. public:
  10. //! Writes to the resource
  11. //! \param bytes An array containing the bytes to be written to the
  12. //! resource
  13. //! \param len How many bytes should be written to the resource
  14. virtual void write(const char* bytes, int len) = 0;
  15. //! Checks whether the resource has been fully written
  16. //! return 1 if the resource has been fully written. 0 otherwise
  17. virtual bool isEnd() const = 0;
  18. };
  19. class Writer : public StreamWriter
  20. {
  21. public:
  22. //! Sets the position of the byte to be written next
  23. //! \param pos The index of the byte
  24. //! \param ende 1 if the index counts from the end of the resource. 0 if
  25. //! the index counts from the beginning of the resource
  26. virtual void setSPosition(__int64 pos, bool ende) = 0;
  27. //! Returns the index of the byte from the resource that would be written next
  28. //! return -1 if an error occurred. Otherwise the position of the write pointer
  29. virtual __int64 getSPosition() const = 0;
  30. //! Returns the number of bytes to be written
  31. virtual __int64 getSize() const = 0;
  32. };
  33. class OStreamWriter : public StreamWriter
  34. {
  35. private:
  36. std::ostream& out;
  37. public:
  38. __declspec(dllexport) OStreamWriter(std::ostream& out);
  39. __declspec(dllexport) void write(
  40. const char* bytes, int len) override;
  41. __declspec(dllexport) bool isEnd() const override;
  42. };
  43. } // namespace Framework