aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io/Stream.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-13 18:25:45 +0800
committercrupest <crupest@outlook.com>2022-01-13 18:25:45 +0800
commitd4d9c6810954010e5de23aba19244f59f2139e41 (patch)
treed2e3277cc7e1f352f1aa5f865b7c7450b9fe4247 /include/cru/common/io/Stream.hpp
parent276ae73fa444c16f34a379ae9d8f58c883056b4a (diff)
downloadcru-d4d9c6810954010e5de23aba19244f59f2139e41.tar.gz
cru-d4d9c6810954010e5de23aba19244f59f2139e41.tar.bz2
cru-d4d9c6810954010e5de23aba19244f59f2139e41.zip
...
Diffstat (limited to 'include/cru/common/io/Stream.hpp')
-rw-r--r--include/cru/common/io/Stream.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/cru/common/io/Stream.hpp b/include/cru/common/io/Stream.hpp
new file mode 100644
index 00000000..e13e5388
--- /dev/null
+++ b/include/cru/common/io/Stream.hpp
@@ -0,0 +1,36 @@
+#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() = 0;
+};
+} // namespace cru::io