aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
diff options
context:
space:
mode:
authorKamil Domanski <kdomanski@kdemail.net>2014-08-20 22:44:38 +0200
committerKamil Domanski <kdomanski@kdemail.net>2014-08-31 02:16:17 +0200
commit84881f8c472cc67dc757686eb7dc3b495b13cab8 (patch)
tree9aa2ae012cc4817464cb60e9d838fa92464a9477 /src/serialize.h
parent5d96b4ae0188fcad36105642c5d69249d37fdbb5 (diff)
rework overhauled serialization methods to non-static
Thanks to Pieter Wuille for most of the work on this commit. I did not fixup the overhaul commit, because a rebase conflicted with "remove fields of ser_streamplaceholder". I prefer not to risk making a mistake while resolving it.
Diffstat (limited to 'src/serialize.h')
-rw-r--r--src/serialize.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/serialize.h b/src/serialize.h
index c0666d30a5..6eefa18135 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -38,12 +38,12 @@ inline T& REF(const T& val)
return const_cast<T&>(val);
}
-// Used to acquire a const pointer "this" and generate a const
-// serialization operation from a template
+// Used to acquire a non-const pointer "this" to generate bodies
+// of const serialization operations from a template
template<typename T>
-inline T MAKE_CONST(T val)
+inline T* NCONST_PTR(const T* val)
{
- return const_cast<const T>(val);
+ return const_cast<T*>(val);
}
/** Get begin pointer of vector (non-const version).
@@ -97,15 +97,15 @@ enum
#define IMPLEMENT_SERIALIZE \
size_t GetSerializeSize(int nType, int nVersion) const { \
ser_streamplaceholder s; \
- return SerializationOp(MAKE_CONST(this), s, CSerActionGetSerializeSize(), nType, nVersion); \
+ return NCONST_PTR(this)->SerializationOp(s, CSerActionGetSerializeSize(), nType, nVersion); \
} \
template<typename Stream> \
void Serialize(Stream& s, int nType, int nVersion) const { \
- SerializationOp(MAKE_CONST(this), s, CSerActionSerialize(), nType, nVersion); \
+ NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion); \
} \
template<typename Stream> \
void Unserialize(Stream& s, int nType, int nVersion) { \
- SerializationOp(this, s, CSerActionUnserialize(), nType, nVersion); \
+ SerializationOp(s, CSerActionUnserialize(), nType, nVersion); \
}