CMemoryStream.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. /*
  3. * CMemoryStream.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "CInputStream.h"
  12. /**
  13. * A class which provides method definitions for reading from memory.
  14. * @deprecated use CMemoryBuffer
  15. */
  16. class DLL_LINKAGE CMemoryStream : public CInputStream
  17. {
  18. public:
  19. /**
  20. * C-tor. The data buffer won't be free'd. (no ownership)
  21. *
  22. * @param data a pointer to the data array.
  23. * @param size The size in bytes of the array.
  24. */
  25. CMemoryStream(const ui8 * data, si64 size);
  26. /**
  27. * Reads n bytes from the stream into the data buffer.
  28. *
  29. * @param data A pointer to the destination data array.
  30. * @param size The number of bytes to read.
  31. * @return the number of bytes read actually.
  32. */
  33. si64 read(ui8 * data, si64 size) override;
  34. /**
  35. * Seeks the internal read pointer to the specified position.
  36. *
  37. * @param position The read position from the beginning.
  38. * @return the position actually moved to, -1 on error.
  39. */
  40. si64 seek(si64 position) override;
  41. /**
  42. * Gets the current read position in the stream.
  43. *
  44. * @return the read position.
  45. */
  46. si64 tell() override;
  47. /**
  48. * Skips delta numbers of bytes.
  49. *
  50. * @param delta The count of bytes to skip.
  51. * @return the count of bytes skipped actually.
  52. */
  53. si64 skip(si64 delta) override;
  54. /**
  55. * Gets the length in bytes of the stream.
  56. *
  57. * @return the length in bytes of the stream.
  58. */
  59. si64 getSize() override;
  60. private:
  61. /** A pointer to the data array. */
  62. const ui8 * data;
  63. /** The size in bytes of the array. */
  64. si64 size;
  65. /** Current reading position of the stream. */
  66. si64 position;
  67. };