mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
serialization: teach serializers variadics
Also add a variadic CDataStream ctor for ease-of-use.
This commit is contained in:
committed by
Pieter Wuille
parent
82077ef6e4
commit
b98c14c4e3
@@ -160,6 +160,7 @@ enum
|
||||
};
|
||||
|
||||
#define READWRITE(obj) (::SerReadWrite(s, (obj), nType, nVersion, ser_action))
|
||||
#define READWRITEMANY(...) (::SerReadWriteMany(s, nType, nVersion, ser_action, __VA_ARGS__))
|
||||
|
||||
/**
|
||||
* Implement three methods for serializable objects. These are actually wrappers over
|
||||
@@ -960,4 +961,52 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Stream>
|
||||
void SerializeMany(Stream& s, int nType, int nVersion)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Stream, typename Arg>
|
||||
void SerializeMany(Stream& s, int nType, int nVersion, Arg&& arg)
|
||||
{
|
||||
::Serialize(s, std::forward<Arg>(arg), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream, typename Arg, typename... Args>
|
||||
void SerializeMany(Stream& s, int nType, int nVersion, Arg&& arg, Args&&... args)
|
||||
{
|
||||
::Serialize(s, std::forward<Arg>(arg), nType, nVersion);
|
||||
::SerializeMany(s, nType, nVersion, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
inline void UnserializeMany(Stream& s, int nType, int nVersion)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Stream, typename Arg>
|
||||
inline void UnserializeMany(Stream& s, int nType, int nVersion, Arg& arg)
|
||||
{
|
||||
::Unserialize(s, arg, nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream, typename Arg, typename... Args>
|
||||
inline void UnserializeMany(Stream& s, int nType, int nVersion, Arg& arg, Args&... args)
|
||||
{
|
||||
::Unserialize(s, arg, nType, nVersion);
|
||||
::UnserializeMany(s, nType, nVersion, args...);
|
||||
}
|
||||
|
||||
template<typename Stream, typename... Args>
|
||||
inline void SerReadWriteMany(Stream& s, int nType, int nVersion, CSerActionSerialize ser_action, Args&&... args)
|
||||
{
|
||||
::SerializeMany(s, nType, nVersion, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename Stream, typename... Args>
|
||||
inline void SerReadWriteMany(Stream& s, int nType, int nVersion, CSerActionUnserialize ser_action, Args&... args)
|
||||
{
|
||||
::UnserializeMany(s, nType, nVersion, args...);
|
||||
}
|
||||
|
||||
#endif // BITCOIN_SERIALIZE_H
|
||||
|
||||
Reference in New Issue
Block a user