Get rid of nType and nVersion
Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
This commit is contained in:
committed by
Jack Grigg
parent
a8e5ae92ba
commit
242f1421db
@@ -85,7 +85,7 @@ public:
|
||||
CBaseDataStream(int nTypeIn, int nVersionIn, Args&&... args)
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
::SerializeMany(*this, nType, nVersion, std::forward<Args>(args)...);
|
||||
::SerializeMany(*this, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void Init(int nTypeIn, int nVersionIn)
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s, int nType, int nVersion) const
|
||||
void Serialize(Stream& s) const
|
||||
{
|
||||
// Special case: stream << stream concatenates like stream += stream
|
||||
if (!vch.empty())
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
CBaseDataStream& operator<<(const T& obj)
|
||||
{
|
||||
// Serialize to this stream
|
||||
::Serialize(*this, obj, nType, nVersion);
|
||||
::Serialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
CBaseDataStream& operator>>(T& obj)
|
||||
{
|
||||
// Unserialize from this stream
|
||||
::Unserialize(*this, obj, nType, nVersion);
|
||||
::Unserialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ public:
|
||||
// Serialize to this stream
|
||||
if (!file)
|
||||
throw std::ios_base::failure("CAutoFile::operator<<: file handle is NULL");
|
||||
::Serialize(*this, obj, nType, nVersion);
|
||||
::Serialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ public:
|
||||
// Unserialize from this stream
|
||||
if (!file)
|
||||
throw std::ios_base::failure("CAutoFile::operator>>: file handle is NULL");
|
||||
::Unserialize(*this, obj, nType, nVersion);
|
||||
::Unserialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
};
|
||||
@@ -497,6 +497,9 @@ public:
|
||||
fclose();
|
||||
}
|
||||
|
||||
int GetVersion() const { return nVersion; }
|
||||
int GetType() const { return nType; }
|
||||
|
||||
void fclose()
|
||||
{
|
||||
if (src) {
|
||||
@@ -575,7 +578,7 @@ public:
|
||||
template<typename T>
|
||||
CBufferedFile& operator>>(T& obj) {
|
||||
// Unserialize from this stream
|
||||
::Unserialize(*this, obj, nType, nVersion);
|
||||
::Unserialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user