From b069750d3f27c96a83700a08a2bb819902268857 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 10 Jul 2014 20:16:58 +0200 Subject: Break up CAddrMan's IMPLEMENT_SERIALIZE --- src/serialize.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/serialize.h') diff --git a/src/serialize.h b/src/serialize.h index 5ac85554c..f876efd9b 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -830,6 +830,35 @@ struct ser_streamplaceholder typedef std::vector > CSerializeData; +class CSizeComputer +{ +protected: + size_t nSize; + +public: + int nType; + int nVersion; + + CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {} + + CSizeComputer& write(const char *psz, int nSize) + { + this->nSize += nSize; + return *this; + } + + template + CSizeComputer& operator<<(const T& obj) + { + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } + + size_t size() const { + return nSize; + } +}; + /** Double ended buffer combining vector and stream-like interfaces. * * >> and << read and write unformatted data using the above serialization templates. -- cgit v1.2.3