aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io/ProxyStream.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-10-06 13:57:39 +0800
committercrupest <crupest@outlook.com>2024-10-06 13:57:39 +0800
commitdfe62dcf8bcefc523b466e127c3edc4dc2756629 (patch)
tree1c751a14ba0da07ca2ff805633f97568060aa4c9 /include/cru/common/io/ProxyStream.h
parentf51eb955e188858272230a990565931e7403f23b (diff)
downloadcru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.tar.gz
cru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.tar.bz2
cru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.zip
Rename common to base.
Diffstat (limited to 'include/cru/common/io/ProxyStream.h')
-rw-r--r--include/cru/common/io/ProxyStream.h42
1 files changed, 0 insertions, 42 deletions
diff --git a/include/cru/common/io/ProxyStream.h b/include/cru/common/io/ProxyStream.h
deleted file mode 100644
index 42ec9dfd..00000000
--- a/include/cru/common/io/ProxyStream.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include "Stream.h"
-
-#include <functional>
-
-namespace cru::io {
-struct ProxyStreamHandlers {
- std::function<Index(Index offset, Stream::SeekOrigin origin)> seek;
- std::function<Index(std::byte* buffer, Index offset, Index size)> read;
- std::function<Index(const std::byte* buffer, Index offset, Index size)> write;
- std::function<void()> flush;
-
- /**
- * @brief This method will be only called once when `Close` is called or the
- * stream is destructed.
- */
- std::function<void()> close;
-};
-
-class ProxyStream : public Stream {
- public:
- explicit ProxyStream(ProxyStreamHandlers handlers);
-
- ~ProxyStream() override;
-
- public:
- CRU_STREAM_IMPLEMENT_CLOSE_BY_DO_CLOSE
-
- protected:
- Index DoSeek(Index offset, SeekOrigin origin) override;
- Index DoRead(std::byte* buffer, Index offset, Index size) override;
- Index DoWrite(const std::byte* buffer, Index offset, Index size) override;
- void DoFlush() override;
-
- private:
- void DoClose();
-
- private:
- ProxyStreamHandlers handlers_;
-};
-} // namespace cru::io