aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/Exception.hpp3
-rw-r--r--include/cru/common/io/MemoryStream.hpp11
2 files changed, 10 insertions, 4 deletions
diff --git a/include/cru/common/Exception.hpp b/include/cru/common/Exception.hpp
index e8395178..cb35469c 100644
--- a/include/cru/common/Exception.hpp
+++ b/include/cru/common/Exception.hpp
@@ -2,6 +2,9 @@
#include "String.hpp"
namespace cru {
+#ifdef _MSC_VER
+#pragma warning(disable : 4275)
+#endif
class CRU_BASE_API Exception : public std::exception {
public:
Exception();
diff --git a/include/cru/common/io/MemoryStream.hpp b/include/cru/common/io/MemoryStream.hpp
index 070ef2c6..a1be1354 100644
--- a/include/cru/common/io/MemoryStream.hpp
+++ b/include/cru/common/io/MemoryStream.hpp
@@ -2,16 +2,19 @@
#include "Stream.hpp"
+#include <functional>
+
namespace cru::io {
class CRU_BASE_API MemoryStream : public Stream {
public:
MemoryStream() = default;
- MemoryStream(std::byte* buffer, Index size, bool read_only = false,
- bool auto_release = false)
+ MemoryStream(
+ std::byte* buffer, Index size, bool read_only = false,
+ std::function<void(std::byte* buffer, Index size)> release_func = {})
: buffer_(buffer),
size_(size),
read_only_(read_only),
- auto_release_(auto_release) {}
+ release_func_(std::move(release_func)) {}
CRU_DELETE_COPY(MemoryStream)
CRU_DELETE_MOVE(MemoryStream)
@@ -33,7 +36,7 @@ class CRU_BASE_API MemoryStream : public Stream {
std::byte* buffer_ = nullptr;
Index size_ = 0;
Index position_ = 0;
- bool auto_release_ = false;
bool read_only_ = false;
+ std::function<void(std::byte* buffer, Index size)> release_func_;
};
} // namespace cru::io