diff options
author | crupest <crupest@outlook.com> | 2023-10-05 21:41:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-05 21:41:32 +0800 |
commit | a5d07d55ef4395a5836fd0d2cd86b94290cb2d07 (patch) | |
tree | 93559c7402df97171b84e43a67aef82d36552da1 /src/common/io/Stream.cpp | |
parent | c1f491712ab071030ed8ca9587c896ca2856ab97 (diff) | |
download | cru-a5d07d55ef4395a5836fd0d2cd86b94290cb2d07.tar.gz cru-a5d07d55ef4395a5836fd0d2cd86b94290cb2d07.tar.bz2 cru-a5d07d55ef4395a5836fd0d2cd86b94290cb2d07.zip |
...
Diffstat (limited to 'src/common/io/Stream.cpp')
-rw-r--r-- | src/common/io/Stream.cpp | 25 |
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); } |