aboutsummaryrefslogtreecommitdiff
path: root/src/serialization/serialization.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/serialization/serialization.h')
-rw-r--r--src/serialization/serialization.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h
index d0f9ee0f7..3ebeed171 100644
--- a/src/serialization/serialization.h
+++ b/src/serialization/serialization.h
@@ -48,6 +48,7 @@
#include <string>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/integral_constant.hpp>
+#include <boost/mpl/bool.hpp>
/*! \struct is_blob_type
*
@@ -278,6 +279,27 @@ inline bool do_serialize(Archive &ar, bool &v)
if (!ar.stream().good()) return false; \
} while(0);
+/*! \macro MAGIC_FIELD(m)
+ */
+#define MAGIC_FIELD(m) \
+ std::string magic = m; \
+ do { \
+ ar.tag("magic"); \
+ ar.serialize_blob((void*)magic.data(), magic.size()); \
+ if (!ar.stream().good()) return false; \
+ if (magic != m) return false; \
+ } while(0);
+
+/*! \macro VERSION_FIELD(v)
+ */
+#define VERSION_FIELD(v) \
+ uint32_t version = v; \
+ do { \
+ ar.tag("version"); \
+ ar.serialize_varint(version); \
+ if (!ar.stream().good()) return false; \
+ } while(0);
+
namespace serialization {
/*! \namespace detail