aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-15 22:41:11 +0800
committercrupest <crupest@outlook.com>2022-01-15 22:41:11 +0800
commit570e95f4551385a81eb2cf6f2e386e3b0cb291a8 (patch)
tree8ed08ab29f49b260ac66e88a75aa436c4daefb57 /include
parentabb9d48a72e2d580d6bfbfcb600795c5ec66e204 (diff)
downloadcru-570e95f4551385a81eb2cf6f2e386e3b0cb291a8.tar.gz
cru-570e95f4551385a81eb2cf6f2e386e3b0cb291a8.tar.bz2
cru-570e95f4551385a81eb2cf6f2e386e3b0cb291a8.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/Exception.hpp11
-rw-r--r--include/cru/common/io/Stream.hpp2
-rw-r--r--include/cru/common/io/UnixFileStream.hpp4
3 files changed, 12 insertions, 5 deletions
diff --git a/include/cru/common/Exception.hpp b/include/cru/common/Exception.hpp
index 4e5d3a16..e8395178 100644
--- a/include/cru/common/Exception.hpp
+++ b/include/cru/common/Exception.hpp
@@ -2,21 +2,24 @@
#include "String.hpp"
namespace cru {
-class CRU_BASE_API Exception {
+class CRU_BASE_API Exception : public std::exception {
public:
- Exception() = default;
- explicit Exception(String message) : message_(std::move(message)) {}
+ Exception();
+ explicit Exception(String message);
CRU_DEFAULT_COPY(Exception)
CRU_DEFAULT_MOVE(Exception)
- virtual ~Exception() = default;
+ ~Exception() override;
public:
String GetMessage() const { return message_; }
+ const char* what() const noexcept override;
+
private:
String message_;
+ mutable std::string utf8_message_;
};
class CRU_BASE_API TextEncodeException : public Exception {
diff --git a/include/cru/common/io/Stream.hpp b/include/cru/common/io/Stream.hpp
index d75f3ee3..fedd4a0f 100644
--- a/include/cru/common/io/Stream.hpp
+++ b/include/cru/common/io/Stream.hpp
@@ -30,6 +30,8 @@ class CRU_BASE_API Stream : public Object {
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);
+ Index Write(const char* buffer, Index offset, Index size);
+ Index Write(const char* buffer, Index size);
virtual void Flush();
diff --git a/include/cru/common/io/UnixFileStream.hpp b/include/cru/common/io/UnixFileStream.hpp
index 8bd3829a..633b9bd1 100644
--- a/include/cru/common/io/UnixFileStream.hpp
+++ b/include/cru/common/io/UnixFileStream.hpp
@@ -25,9 +25,11 @@ class UnixFileStream : public Stream {
bool CanRead() override;
Index Read(std::byte* buffer, Index offset, Index size) override;
+ using Stream::Read;
bool CanWrite() override;
Index Write(const std::byte* buffer, Index offset, Index size) override;
+ using Stream::Write;
void Close() override;
@@ -36,7 +38,7 @@ class UnixFileStream : public Stream {
private:
String path_;
- OpenFileFlag flags;
+ OpenFileFlag flags_;
int file_descriptor_;
bool closed_ = false;
};