File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,6 +413,7 @@ I ReadVarInt(Stream& is)
413413
414414#define FLATDATA (obj ) REF (CFlatData((char *)&(obj), (char *)&(obj) + sizeof (obj)))
415415#define VARINT (obj ) REF (WrapVarInt(REF (obj)))
416+ #define COMPACTSIZE (obj ) REF (CCompactSize(REF (obj)))
416417#define LIMITED_STRING (obj, n ) REF (LimitedString<n>(REF (obj)))
417418
418419/* *
@@ -488,6 +489,28 @@ class CVarInt
488489 }
489490};
490491
492+ class CCompactSize
493+ {
494+ protected:
495+ uint64_t &n;
496+ public:
497+ CCompactSize (uint64_t & nIn) : n(nIn) { }
498+
499+ unsigned int GetSerializeSize (int , int ) const {
500+ return GetSizeOfCompactSize (n);
501+ }
502+
503+ template <typename Stream>
504+ void Serialize (Stream &s, int , int ) const {
505+ WriteCompactSize<Stream>(s, n);
506+ }
507+
508+ template <typename Stream>
509+ void Unserialize (Stream& s, int , int ) {
510+ n = ReadCompactSize<Stream>(s);
511+ }
512+ };
513+
491514template <size_t Limit>
492515class LimitedString
493516{
You can’t perform that action at this time.
0 commit comments