Changeset View
Changeset View
Standalone View
Standalone View
src/serialize.h
Show First 20 Lines • Show All 1,120 Lines • ▼ Show 20 Lines | public: | ||||
size_t size() const { return nSize; } | size_t size() const { return nSize; } | ||||
int GetVersion() const { return nVersion; } | int GetVersion() const { return nVersion; } | ||||
}; | }; | ||||
template <typename Stream> void SerializeMany(Stream &s) {} | template <typename Stream> void SerializeMany(Stream &s) {} | ||||
template <typename Stream, typename Arg, typename... Args> | template <typename Stream, typename Arg, typename... Args> | ||||
void SerializeMany(Stream &s, const Arg &arg, const Args &... args) { | void SerializeMany(Stream &s, const Arg &arg, const Args &...args) { | ||||
::Serialize(s, arg); | ::Serialize(s, arg); | ||||
::SerializeMany(s, args...); | ::SerializeMany(s, args...); | ||||
} | } | ||||
template <typename Stream> inline void UnserializeMany(Stream &s) {} | template <typename Stream> inline void UnserializeMany(Stream &s) {} | ||||
template <typename Stream, typename Arg, typename... Args> | template <typename Stream, typename Arg, typename... Args> | ||||
inline void UnserializeMany(Stream &s, Arg &&arg, Args &&... args) { | inline void UnserializeMany(Stream &s, Arg &&arg, Args &&...args) { | ||||
::Unserialize(s, arg); | ::Unserialize(s, arg); | ||||
::UnserializeMany(s, args...); | ::UnserializeMany(s, args...); | ||||
} | } | ||||
template <typename Stream, typename... Args> | template <typename Stream, typename... Args> | ||||
inline void SerReadWriteMany(Stream &s, CSerActionSerialize ser_action, | inline void SerReadWriteMany(Stream &s, CSerActionSerialize ser_action, | ||||
const Args &... args) { | const Args &...args) { | ||||
::SerializeMany(s, args...); | ::SerializeMany(s, args...); | ||||
} | } | ||||
template <typename Stream, typename... Args> | template <typename Stream, typename... Args> | ||||
inline void SerReadWriteMany(Stream &s, CSerActionUnserialize ser_action, | inline void SerReadWriteMany(Stream &s, CSerActionUnserialize ser_action, | ||||
Args &&... args) { | Args &&...args) { | ||||
::UnserializeMany(s, args...); | ::UnserializeMany(s, args...); | ||||
} | } | ||||
template <typename Stream, typename Type, typename Fn> | template <typename Stream, typename Type, typename Fn> | ||||
inline void SerRead(Stream &s, CSerActionSerialize ser_action, Type &&, Fn &&) { | inline void SerRead(Stream &s, CSerActionSerialize ser_action, Type &&, Fn &&) { | ||||
} | } | ||||
template <typename Stream, typename Type, typename Fn> | template <typename Stream, typename Type, typename Fn> | ||||
Show All 20 Lines | inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize) { | ||||
s.seek(GetSizeOfCompactSize(nSize)); | s.seek(GetSizeOfCompactSize(nSize)); | ||||
} | } | ||||
template <typename T> size_t GetSerializeSize(const T &t, int nVersion = 0) { | template <typename T> size_t GetSerializeSize(const T &t, int nVersion = 0) { | ||||
return (CSizeComputer(nVersion) << t).size(); | return (CSizeComputer(nVersion) << t).size(); | ||||
} | } | ||||
template <typename... T> | template <typename... T> | ||||
size_t GetSerializeSizeMany(int nVersion, const T &... t) { | size_t GetSerializeSizeMany(int nVersion, const T &...t) { | ||||
CSizeComputer sc(nVersion); | CSizeComputer sc(nVersion); | ||||
SerializeMany(sc, t...); | SerializeMany(sc, t...); | ||||
return sc.size(); | return sc.size(); | ||||
} | } | ||||
#endif // BITCOIN_SERIALIZE_H | #endif // BITCOIN_SERIALIZE_H |