@@ -468,26 +468,22 @@ class Wrapper
468468template <typename Formatter, typename T>
469469static inline Wrapper<Formatter, T&> Using (T&& t) { return Wrapper<Formatter, T&>(t); }
470470
471- #define VARINT (obj, ...) WrapVarInt< __VA_ARGS__>(REF( obj) )
471+ #define VARINT (obj, ...) Using<VarIntFormatter< __VA_ARGS__>>( obj)
472472#define COMPACTSIZE (obj ) CCompactSize(REF(obj))
473473#define LIMITED_STRING (obj,n ) LimitedString< n >(REF(obj))
474474
475- template <VarIntMode Mode, typename I>
476- class CVarInt
475+ /* * Serialization wrapper class for integers in VarInt format. */
476+ template <VarIntMode Mode=VarIntMode::DEFAULT>
477+ struct VarIntFormatter
477478{
478- protected:
479- I &n;
480- public:
481- explicit CVarInt (I& nIn) : n(nIn) { }
482-
483- template <typename Stream>
484- void Serialize (Stream &s) const {
485- WriteVarInt<Stream,Mode,I>(s, n);
479+ template <typename Stream, typename I> void Ser (Stream &s, I v)
480+ {
481+ WriteVarInt<Stream,Mode,typename std::remove_cv<I>::type>(s, v);
486482 }
487483
488- template <typename Stream>
489- void Unserialize (Stream& s) {
490- n = ReadVarInt<Stream,Mode,I >(s);
484+ template <typename Stream, typename I> void Unser (Stream& s, I& v)
485+ {
486+ v = ReadVarInt<Stream,Mode,typename std::remove_cv<I>::type >(s);
491487 }
492488};
493489
@@ -572,9 +568,6 @@ class LimitedString
572568 }
573569};
574570
575- template <VarIntMode Mode=VarIntMode::DEFAULT, typename I>
576- CVarInt<Mode, I> WrapVarInt (I& n) { return CVarInt<Mode, I>{n}; }
577-
578571template <typename I>
579572BigEndian<I> WrapBigEndian (I& n) { return BigEndian<I>(n); }
580573
0 commit comments