aboutsummaryrefslogtreecommitdiff
path: root/src/common/io/Stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/io/Stream.cpp')
-rw-r--r--src/common/io/Stream.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common/io/Stream.cpp b/src/common/io/Stream.cpp
index bc045f03..07677fa8 100644
--- a/src/common/io/Stream.cpp
+++ b/src/common/io/Stream.cpp
@@ -1,6 +1,31 @@
#include "cru/common/io/Stream.h"
+#include "cru/common/Format.h"
+
+#include <utility>
namespace cru::io {
+StreamOperationNotSupportedException::StreamOperationNotSupportedException(
+ String operation)
+ : operation_(std::move(operation)) {
+ SetMessage(Format(u"Stream operation {} not supported.", operation_));
+}
+
+void StreamOperationNotSupportedException::CheckSeek(bool seekable) {
+ if (!seekable) throw StreamOperationNotSupportedException(u"seek");
+}
+
+void StreamOperationNotSupportedException::CheckRead(bool readable) {
+ if (!readable) throw StreamOperationNotSupportedException(u"read");
+}
+
+void StreamOperationNotSupportedException::CheckWrite(bool writable) {
+ if (!writable) throw StreamOperationNotSupportedException(u"write");
+}
+
+void StreamAlreadyClosedException::Check(bool closed) {
+ if (closed) throw StreamAlreadyClosedException();
+}
+
Index Stream::Tell() { return Seek(0, SeekOrigin::Current); }
void Stream::Rewind() { Seek(0, SeekOrigin::Begin); }