From b8c1dda66e6f184c5ed09f8619324720ea27c76e Mon Sep 17 00:00:00 2001 From: furszy Date: Thu, 10 Jun 2021 19:47:58 -0300 Subject: [PATCH] streams update: get rid of nType and nVersion. Plus support deserializing into temporaries --- src/streams.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/streams.h b/src/streams.h index 129a6c9a398ab..7fa9a2e88ab94 100644 --- a/src/streams.h +++ b/src/streams.h @@ -38,7 +38,7 @@ class OverrideStream OverrideStream& operator<<(const T& obj) { // Serialize to this stream - ::Serialize(*this->stream, obj, nType, nVersion); + ::Serialize(*this, obj); return (*this); } @@ -46,9 +46,23 @@ class OverrideStream OverrideStream& operator>>(T&& obj) { // Unserialize from this stream - ::Unserialize(*this->stream, obj, nType, nVersion); + ::Unserialize(*this, obj); return (*this); } + + void write(const char* pch, size_t nSize) + { + stream->write(pch, nSize); + } + + void read(char* pch, size_t nSize) + { + stream->read(pch, nSize); + } + + int GetVersion() const { return nVersion; } + int GetType() const { return nType; } + size_t size() const { return stream->size(); } }; /** Double ended buffer combining vector and stream-like interfaces. @@ -594,6 +608,9 @@ class CBufferedFile fclose(); } + int GetVersion() const { return nVersion; } + int GetType() const { return nType; } + // Disallow copies CBufferedFile(const CBufferedFile&) = delete; CBufferedFile& operator=(const CBufferedFile&) = delete;