Skip to content

Commit

Permalink
streams update: get rid of nType and nVersion.
Browse files Browse the repository at this point in the history
Plus support deserializing into temporaries
  • Loading branch information
furszy committed Aug 10, 2021
1 parent 3eaa273 commit b8c1dda
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,31 @@ class OverrideStream
OverrideStream<Stream>& operator<<(const T& obj)
{
// Serialize to this stream
::Serialize(*this->stream, obj, nType, nVersion);
::Serialize(*this, obj);
return (*this);
}

template<typename T>
OverrideStream<Stream>& 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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b8c1dda

Please sign in to comment.