aboutsummaryrefslogtreecommitdiff
path: root/src/common/io/ProxyStream.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-12-25 22:16:13 +0800
committercrupest <crupest@outlook.com>2023-12-25 22:16:13 +0800
commit29bef137f5c33a599f2629fecc0b756611dd126b (patch)
tree486efa5ce66dc4b71949c7f845c0b50c4ea2ca04 /src/common/io/ProxyStream.cpp
parent8fa5b665ddb5a6b1d609b81b66b57dbce7473bc6 (diff)
downloadcru-29bef137f5c33a599f2629fecc0b756611dd126b.tar.gz
cru-29bef137f5c33a599f2629fecc0b756611dd126b.tar.bz2
cru-29bef137f5c33a599f2629fecc0b756611dd126b.zip
Add proxy stream (not completed).
Diffstat (limited to 'src/common/io/ProxyStream.cpp')
-rw-r--r--src/common/io/ProxyStream.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/io/ProxyStream.cpp b/src/common/io/ProxyStream.cpp
new file mode 100644
index 00000000..9fd6be76
--- /dev/null
+++ b/src/common/io/ProxyStream.cpp
@@ -0,0 +1,18 @@
+#include "cru/common/io/ProxyStream.h"
+#include "cru/common/io/Stream.h"
+
+namespace cru::io {
+ProxyStream::ProxyStream(ProxyStreamHandlers handlers)
+ : closed_(false), handlers_(std::move(handlers)) {}
+
+ProxyStream::~ProxyStream() { DoClose(); }
+
+void ProxyStream::DoClose() {
+ if (!closed_) {
+ if (handlers_.close) {
+ handlers_.close();
+ }
+ closed_ = true;
+ }
+}
+} // namespace cru::io