50
50
#include < boost/type_traits/integral_constant.hpp>
51
51
#include < boost/mpl/bool.hpp>
52
52
53
+ #include " common/va_args.h"
54
+
53
55
/* ! \struct is_blob_type / is_blob_forced
54
56
*
55
57
* \brief descriptors for dispatching serialize: whether to take byte-wise copy/store to type
@@ -93,6 +95,15 @@ inline bool do_serialize(Archive &ar, bool &v)
93
95
ar.serialize_blob (&v, sizeof (v));
94
96
return true ;
95
97
}
98
+ template <class Archive , class T , typename ... Args>
99
+ inline auto do_serialize (Archive &ar, T &v, Args&&... args)
100
+ -> decltype(do_serialize_object(ar, v, args...), true)
101
+ {
102
+ ar.begin_object ();
103
+ const bool r = do_serialize_object (ar, v, args...);
104
+ ar.end_object ();
105
+ return r && ar.good ();
106
+ }
96
107
97
108
/* the following add a trait to a set and define the serialization DSL*/
98
109
@@ -180,18 +191,9 @@ inline bool do_serialize(Archive &ar, bool &v)
180
191
* VARINT_FIELD_F(). Otherwise, this macro is similar to
181
192
* BEGIN_SERIALIZE_OBJECT(), as you should list only field serializations.
182
193
*/
183
- #define BEGIN_SERIALIZE_OBJECT_FN (stype ) \
184
- template <bool W, template <bool > class Archive > \
185
- bool do_serialize_object (Archive<W> &ar, stype &v); \
186
- template <bool W, template <bool > class Archive > \
187
- bool do_serialize (Archive<W> &ar, stype &v) { \
188
- ar.begin_object (); \
189
- bool r = do_serialize_object (ar, v); \
190
- ar.end_object (); \
191
- return r; \
192
- } \
193
- template <bool W, template <bool > class Archive > \
194
- bool do_serialize_object (Archive<W> &ar, stype &v) { \
194
+ #define BEGIN_SERIALIZE_OBJECT_FN (stype, ...) \
195
+ template <bool W, template <bool > class Archive > \
196
+ bool do_serialize_object (Archive<W> &ar, stype &v VA_ARGS_COMMAPREFIX (__VA_ARGS__)) {
195
197
196
198
/* ! \macro PREPARE_CUSTOM_VECTOR_SERIALIZATION
197
199
*/
@@ -209,10 +211,10 @@ inline bool do_serialize(Archive &ar, bool &v)
209
211
*
210
212
* \brief serializes a field \a f tagged \a t
211
213
*/
212
- #define FIELD_N (t, f ) \
214
+ #define FIELD_N (t, f, ...) \
213
215
do { \
214
216
ar.tag (t); \
215
- bool r = do_serialize (ar, f); \
217
+ bool r = do_serialize (ar, f VA_ARGS_COMMAPREFIX (__VA_ARGS__)); \
216
218
if (!r || !ar.good ()) return false ; \
217
219
} while (0 );
218
220
@@ -231,7 +233,7 @@ inline bool do_serialize(Archive &ar, bool &v)
231
233
*
232
234
* \brief tags the field with the variable name and then serializes it (for use in a free function)
233
235
*/
234
- #define FIELD_F (f ) FIELD_N(#f, v.f)
236
+ #define FIELD_F (f, ... ) FIELD_N(#f, v.f VA_ARGS_COMMAPREFIX (__VA_ARGS__) )
235
237
236
238
/* ! \macro FIELDS(f)
237
239
*
0 commit comments