aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io/Stream.hpp
blob: d75f3ee3e3381bca6cd8f37cdf087d8d63719aa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include "../Base.hpp"

#include <cstddef>

namespace cru::io {
class CRU_BASE_API Stream : public Object {
 public:
  enum class SeekOrigin { Current, Begin, End };

  Stream() = default;

  CRU_DELETE_COPY(Stream)
  CRU_DELETE_MOVE(Stream)

  ~Stream() override = default;

 public:
  virtual bool CanSeek() = 0;
  virtual Index Tell() = 0;
  virtual void Seek(Index offset, SeekOrigin origin = SeekOrigin::Current) = 0;
  virtual void Rewind();
  virtual Index GetSize();

  virtual bool CanRead() = 0;
  virtual Index Read(std::byte* buffer, Index offset, Index size) = 0;
  virtual Index Read(std::byte* buffer, Index size);

  virtual bool CanWrite() = 0;
  virtual Index Write(const std::byte* buffer, Index offset, Index size) = 0;
  virtual Index Write(const std::byte* buffer, Index size);

  virtual void Flush();

  virtual void Close();
};
}  // namespace cru::io