Derecho  0.9
Distributed systems toolkit for RDMA
SerializationMacros.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <mutils/macro_utils.hpp>
3 
11 #define DEFAULT_SERIALIZE1(a) std::size_t to_bytes(char* ret) const { \
12  return mutils::to_bytes(a, ret); \
13  } \
14  std::size_t bytes_size() const { \
15  return mutils::bytes_size(a) ; \
16  } \
17  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
18  mutils::post_object(func,a); \
19  }
20 
21 #define DEFAULT_SERIALIZE2(a,b) std::size_t to_bytes(char* ret) const { \
22  int bytes_written = mutils::to_bytes(a,ret); \
23  return bytes_written + mutils::to_bytes(b,ret + bytes_written); \
24  } \
25  std::size_t bytes_size() const { \
26  return mutils::bytes_size(a) + mutils::bytes_size(b) ; \
27  } \
28  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
29  mutils::post_object(func,a); \
30  mutils::post_object(func,b); \
31  }
32 
33 #define DEFAULT_SERIALIZE3(a,b,c) std::size_t to_bytes(char* ret) const { \
34  int bytes_written = mutils::to_bytes(a,ret); \
35  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
36  return bytes_written + mutils::to_bytes(c,ret + bytes_written); \
37  } \
38  std::size_t bytes_size() const { \
39  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) ; \
40  } \
41  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
42  mutils::post_object(func,a); \
43  mutils::post_object(func,b); \
44  mutils::post_object(func,c); \
45  }
46 
47 #define DEFAULT_SERIALIZE4(a,b,c,d) std::size_t to_bytes(char* ret) const { \
48  int bytes_written = mutils::to_bytes(a,ret); \
49  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
50  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
51  return bytes_written + mutils::to_bytes(d,ret + bytes_written); \
52  } \
53  std::size_t bytes_size() const { \
54  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) ; \
55  } \
56  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
57  mutils::post_object(func,a); \
58  mutils::post_object(func,b); \
59  mutils::post_object(func,c); \
60  mutils::post_object(func,d); \
61  }
62 
63 #define DEFAULT_SERIALIZE5(a,b,c,d,e) std::size_t to_bytes(char* ret) const { \
64  int bytes_written = mutils::to_bytes(a,ret); \
65  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
66  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
67  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
68  return bytes_written + mutils::to_bytes(e,ret + bytes_written); \
69  } \
70  std::size_t bytes_size() const { \
71  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) ; \
72  } \
73  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
74  mutils::post_object(func,a); \
75  mutils::post_object(func,b); \
76  mutils::post_object(func,c); \
77  mutils::post_object(func,d); \
78  mutils::post_object(func,e); \
79  }
80 
81 #define DEFAULT_SERIALIZE6(a,b,c,d,e,f) std::size_t to_bytes(char* ret) const { \
82  int bytes_written = mutils::to_bytes(a,ret); \
83  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
84  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
85  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
86  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
87  return bytes_written + mutils::to_bytes(f,ret + bytes_written); \
88  } \
89  std::size_t bytes_size() const { \
90  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) ; \
91  } \
92  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
93  mutils::post_object(func,a); \
94  mutils::post_object(func,b); \
95  mutils::post_object(func,c); \
96  mutils::post_object(func,d); \
97  mutils::post_object(func,e); \
98  mutils::post_object(func,f); \
99  }
100 
101 #define DEFAULT_SERIALIZE7(a,b,c,d,e,f,g) std::size_t to_bytes(char* ret) const { \
102  int bytes_written = mutils::to_bytes(a,ret); \
103  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
104  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
105  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
106  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
107  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
108  return bytes_written + mutils::to_bytes(g,ret + bytes_written); \
109  } \
110  std::size_t bytes_size() const { \
111  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) ; \
112  } \
113  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
114  mutils::post_object(func,a); \
115  mutils::post_object(func,b); \
116  mutils::post_object(func,c); \
117  mutils::post_object(func,d); \
118  mutils::post_object(func,e); \
119  mutils::post_object(func,f); \
120  mutils::post_object(func,g); \
121  }
122 
123 #define DEFAULT_SERIALIZE8(a,b,c,d,e,f,g,h) std::size_t to_bytes(char* ret) const { \
124  int bytes_written = mutils::to_bytes(a,ret); \
125  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
126  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
127  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
128  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
129  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
130  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
131  return bytes_written + mutils::to_bytes(h,ret + bytes_written); \
132  } \
133  std::size_t bytes_size() const { \
134  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) ; \
135  } \
136  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
137  mutils::post_object(func,a); \
138  mutils::post_object(func,b); \
139  mutils::post_object(func,c); \
140  mutils::post_object(func,d); \
141  mutils::post_object(func,e); \
142  mutils::post_object(func,f); \
143  mutils::post_object(func,g); \
144  mutils::post_object(func,h); \
145  }
146 
147 #define DEFAULT_SERIALIZE9(a,b,c,d,e,f,g,h,i) std::size_t to_bytes(char* ret) const { \
148  int bytes_written = mutils::to_bytes(a,ret); \
149  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
150  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
151  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
152  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
153  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
154  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
155  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
156  return bytes_written + mutils::to_bytes(i,ret + bytes_written); \
157  } \
158  std::size_t bytes_size() const { \
159  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) ; \
160  } \
161  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
162  mutils::post_object(func,a); \
163  mutils::post_object(func,b); \
164  mutils::post_object(func,c); \
165  mutils::post_object(func,d); \
166  mutils::post_object(func,e); \
167  mutils::post_object(func,f); \
168  mutils::post_object(func,g); \
169  mutils::post_object(func,h); \
170  mutils::post_object(func,i); \
171  }
172 
173 #define DEFAULT_SERIALIZE10(a,b,c,d,e,f,g,h,i,j) std::size_t to_bytes(char* ret) const { \
174  int bytes_written = mutils::to_bytes(a,ret); \
175  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
176  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
177  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
178  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
179  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
180  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
181  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
182  bytes_written += mutils::to_bytes(i,ret + bytes_written); \
183  return bytes_written + mutils::to_bytes(j,ret + bytes_written); \
184  } \
185  std::size_t bytes_size() const { \
186  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) + mutils::bytes_size(j) ; \
187  } \
188  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
189  mutils::post_object(func,a); \
190  mutils::post_object(func,b); \
191  mutils::post_object(func,c); \
192  mutils::post_object(func,d); \
193  mutils::post_object(func,e); \
194  mutils::post_object(func,f); \
195  mutils::post_object(func,g); \
196  mutils::post_object(func,h); \
197  mutils::post_object(func,i); \
198  mutils::post_object(func,j); \
199  }
200 
201 #define DEFAULT_SERIALIZE11(a,b,c,d,e,f,g,h,i,j,k) std::size_t to_bytes(char* ret) const { \
202  int bytes_written = mutils::to_bytes(a,ret); \
203  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
204  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
205  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
206  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
207  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
208  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
209  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
210  bytes_written += mutils::to_bytes(i,ret + bytes_written); \
211  bytes_written += mutils::to_bytes(j,ret + bytes_written); \
212  return bytes_written + mutils::to_bytes(k,ret + bytes_written); \
213  } \
214  std::size_t bytes_size() const { \
215  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) + mutils::bytes_size(j) + mutils::bytes_size(k) ; \
216  } \
217  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
218  mutils::post_object(func,a); \
219  mutils::post_object(func,b); \
220  mutils::post_object(func,c); \
221  mutils::post_object(func,d); \
222  mutils::post_object(func,e); \
223  mutils::post_object(func,f); \
224  mutils::post_object(func,g); \
225  mutils::post_object(func,h); \
226  mutils::post_object(func,i); \
227  mutils::post_object(func,j); \
228  mutils::post_object(func,k); \
229  }
230 
231 #define DEFAULT_SERIALIZE12(a,b,c,d,e,f,g,h,i,j,k,l) std::size_t to_bytes(char* ret) const { \
232  int bytes_written = mutils::to_bytes(a,ret); \
233  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
234  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
235  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
236  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
237  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
238  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
239  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
240  bytes_written += mutils::to_bytes(i,ret + bytes_written); \
241  bytes_written += mutils::to_bytes(j,ret + bytes_written); \
242  bytes_written += mutils::to_bytes(k,ret + bytes_written); \
243  return bytes_written + mutils::to_bytes(l,ret + bytes_written); \
244  } \
245  std::size_t bytes_size() const { \
246  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) + mutils::bytes_size(j) + mutils::bytes_size(k) + mutils::bytes_size(l) ; \
247  } \
248  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
249  mutils::post_object(func,a); \
250  mutils::post_object(func,b); \
251  mutils::post_object(func,c); \
252  mutils::post_object(func,d); \
253  mutils::post_object(func,e); \
254  mutils::post_object(func,f); \
255  mutils::post_object(func,g); \
256  mutils::post_object(func,h); \
257  mutils::post_object(func,i); \
258  mutils::post_object(func,j); \
259  mutils::post_object(func,k); \
260  mutils::post_object(func,l); \
261  }
262 
263 #define DEFAULT_SERIALIZE13(a,b,c,d,e,f,g,h,i,j,k,l,m) std::size_t to_bytes(char* ret) const { \
264  int bytes_written = mutils::to_bytes(a,ret); \
265  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
266  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
267  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
268  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
269  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
270  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
271  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
272  bytes_written += mutils::to_bytes(i,ret + bytes_written); \
273  bytes_written += mutils::to_bytes(j,ret + bytes_written); \
274  bytes_written += mutils::to_bytes(k,ret + bytes_written); \
275  bytes_written += mutils::to_bytes(l,ret + bytes_written); \
276  return bytes_written + mutils::to_bytes(m,ret + bytes_written); \
277  } \
278  std::size_t bytes_size() const { \
279  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) + mutils::bytes_size(j) + mutils::bytes_size(k) + mutils::bytes_size(l) + mutils::bytes_size(m) ; \
280  } \
281  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
282  mutils::post_object(func,a); \
283  mutils::post_object(func,b); \
284  mutils::post_object(func,c); \
285  mutils::post_object(func,d); \
286  mutils::post_object(func,e); \
287  mutils::post_object(func,f); \
288  mutils::post_object(func,g); \
289  mutils::post_object(func,h); \
290  mutils::post_object(func,i); \
291  mutils::post_object(func,j); \
292  mutils::post_object(func,k); \
293  mutils::post_object(func,l); \
294  mutils::post_object(func,m); \
295  }
296 
297 #define DEFAULT_SERIALIZE14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) std::size_t to_bytes(char* ret) const { \
298  int bytes_written = mutils::to_bytes(a,ret); \
299  bytes_written += mutils::to_bytes(b,ret + bytes_written); \
300  bytes_written += mutils::to_bytes(c,ret + bytes_written); \
301  bytes_written += mutils::to_bytes(d,ret + bytes_written); \
302  bytes_written += mutils::to_bytes(e,ret + bytes_written); \
303  bytes_written += mutils::to_bytes(f,ret + bytes_written); \
304  bytes_written += mutils::to_bytes(g,ret + bytes_written); \
305  bytes_written += mutils::to_bytes(h,ret + bytes_written); \
306  bytes_written += mutils::to_bytes(i,ret + bytes_written); \
307  bytes_written += mutils::to_bytes(j,ret + bytes_written); \
308  bytes_written += mutils::to_bytes(k,ret + bytes_written); \
309  bytes_written += mutils::to_bytes(l,ret + bytes_written); \
310  bytes_written += mutils::to_bytes(m,ret + bytes_written); \
311  return bytes_written + mutils::to_bytes(n,ret + bytes_written); \
312  } \
313  std::size_t bytes_size() const { \
314  return mutils::bytes_size(a) + mutils::bytes_size(b) + mutils::bytes_size(c) + mutils::bytes_size(d) + mutils::bytes_size(e) + mutils::bytes_size(f) + mutils::bytes_size(g) + mutils::bytes_size(h) + mutils::bytes_size(i) + mutils::bytes_size(j) + mutils::bytes_size(k) + mutils::bytes_size(l) + mutils::bytes_size(m) + mutils::bytes_size(n) ; \
315  } \
316  void post_object(const std::function<void (char const * const, std::size_t)>& func ) const { \
317  mutils::post_object(func,a); \
318  mutils::post_object(func,b); \
319  mutils::post_object(func,c); \
320  mutils::post_object(func,d); \
321  mutils::post_object(func,e); \
322  mutils::post_object(func,f); \
323  mutils::post_object(func,g); \
324  mutils::post_object(func,h); \
325  mutils::post_object(func,i); \
326  mutils::post_object(func,j); \
327  mutils::post_object(func,k); \
328  mutils::post_object(func,l); \
329  mutils::post_object(func,m); \
330  mutils::post_object(func,n); \
331  }
332 
333 #define DEFAULT_DESERIALIZE2(Name,a) \
334  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
335  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
336  return std::make_unique<Name>(*a_obj); \
337  }
338 
339 #define DEFAULT_DESERIALIZE3(Name,a,b) \
340  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
341  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
342  return std::make_unique<Name>(*a_obj, *(mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + mutils::bytes_size(*a_obj)))); \
343  }
344 
345 #define DEFAULT_DESERIALIZE4(Name,a,b,c) \
346  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
347  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
348  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
349  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
350  return std::make_unique<Name>(*a_obj,*b_obj, *(mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read + mutils::bytes_size(*b_obj)))); \
351  }
352 
353 #define DEFAULT_DESERIALIZE5(Name,a,b,c,d) \
354  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
355  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
356  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
357  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
358  bytes_read += mutils::bytes_size(*b_obj); \
359  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
360  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj, *(mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read + mutils::bytes_size(*c_obj)))); \
361  }
362 
363 #define DEFAULT_DESERIALIZE6(Name,a,b,c,d,e) \
364  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
365  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
366  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
367  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
368  bytes_read += mutils::bytes_size(*b_obj); \
369  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
370  bytes_read += mutils::bytes_size(*c_obj); \
371  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
372  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj, *(mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read + mutils::bytes_size(*d_obj)))); \
373  }
374 
375 #define DEFAULT_DESERIALIZE7(Name,a,b,c,d,e,f) \
376  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
377  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
378  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
379  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
380  bytes_read += mutils::bytes_size(*b_obj); \
381  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
382  bytes_read += mutils::bytes_size(*c_obj); \
383  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
384  bytes_read += mutils::bytes_size(*d_obj); \
385  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
386  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj, *(mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read + mutils::bytes_size(*e_obj)))); \
387  }
388 
389 #define DEFAULT_DESERIALIZE8(Name,a,b,c,d,e,f,g) \
390  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
391  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
392  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
393  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
394  bytes_read += mutils::bytes_size(*b_obj); \
395  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
396  bytes_read += mutils::bytes_size(*c_obj); \
397  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
398  bytes_read += mutils::bytes_size(*d_obj); \
399  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
400  bytes_read += mutils::bytes_size(*e_obj); \
401  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
402  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj, *(mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read + mutils::bytes_size(*f_obj)))); \
403  }
404 
405 #define DEFAULT_DESERIALIZE9(Name,a,b,c,d,e,f,g,h) \
406  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
407  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
408  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
409  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
410  bytes_read += mutils::bytes_size(*b_obj); \
411  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
412  bytes_read += mutils::bytes_size(*c_obj); \
413  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
414  bytes_read += mutils::bytes_size(*d_obj); \
415  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
416  bytes_read += mutils::bytes_size(*e_obj); \
417  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
418  bytes_read += mutils::bytes_size(*f_obj); \
419  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
420  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj, *(mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read + mutils::bytes_size(*g_obj)))); \
421  }
422 
423 #define DEFAULT_DESERIALIZE10(Name,a,b,c,d,e,f,g,h,i) \
424  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
425  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
426  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
427  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
428  bytes_read += mutils::bytes_size(*b_obj); \
429  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
430  bytes_read += mutils::bytes_size(*c_obj); \
431  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
432  bytes_read += mutils::bytes_size(*d_obj); \
433  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
434  bytes_read += mutils::bytes_size(*e_obj); \
435  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
436  bytes_read += mutils::bytes_size(*f_obj); \
437  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
438  bytes_read += mutils::bytes_size(*g_obj); \
439  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
440  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj, *(mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read + mutils::bytes_size(*h_obj)))); \
441  }
442 
443 #define DEFAULT_DESERIALIZE11(Name,a,b,c,d,e,f,g,h,i,j) \
444  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
445  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
446  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
447  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
448  bytes_read += mutils::bytes_size(*b_obj); \
449  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
450  bytes_read += mutils::bytes_size(*c_obj); \
451  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
452  bytes_read += mutils::bytes_size(*d_obj); \
453  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
454  bytes_read += mutils::bytes_size(*e_obj); \
455  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
456  bytes_read += mutils::bytes_size(*f_obj); \
457  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
458  bytes_read += mutils::bytes_size(*g_obj); \
459  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
460  bytes_read += mutils::bytes_size(*h_obj); \
461  auto i_obj = mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read); \
462  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj,*i_obj, *(mutils::from_bytes<std::decay_t<decltype(j)> >(dsm, buf + bytes_read + mutils::bytes_size(*i_obj)))); \
463  }
464 
465 #define DEFAULT_DESERIALIZE12(Name,a,b,c,d,e,f,g,h,i,j,k) \
466  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
467  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
468  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
469  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
470  bytes_read += mutils::bytes_size(*b_obj); \
471  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
472  bytes_read += mutils::bytes_size(*c_obj); \
473  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
474  bytes_read += mutils::bytes_size(*d_obj); \
475  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
476  bytes_read += mutils::bytes_size(*e_obj); \
477  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
478  bytes_read += mutils::bytes_size(*f_obj); \
479  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
480  bytes_read += mutils::bytes_size(*g_obj); \
481  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
482  bytes_read += mutils::bytes_size(*h_obj); \
483  auto i_obj = mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read); \
484  bytes_read += mutils::bytes_size(*i_obj); \
485  auto j_obj = mutils::from_bytes<std::decay_t<decltype(j)> >(dsm, buf + bytes_read); \
486  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj,*i_obj,*j_obj, *(mutils::from_bytes<std::decay_t<decltype(k)> >(dsm, buf + bytes_read + mutils::bytes_size(*j_obj)))); \
487  }
488 
489 #define DEFAULT_DESERIALIZE13(Name,a,b,c,d,e,f,g,h,i,j,k,l) \
490  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
491  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
492  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
493  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
494  bytes_read += mutils::bytes_size(*b_obj); \
495  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
496  bytes_read += mutils::bytes_size(*c_obj); \
497  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
498  bytes_read += mutils::bytes_size(*d_obj); \
499  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
500  bytes_read += mutils::bytes_size(*e_obj); \
501  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
502  bytes_read += mutils::bytes_size(*f_obj); \
503  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
504  bytes_read += mutils::bytes_size(*g_obj); \
505  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
506  bytes_read += mutils::bytes_size(*h_obj); \
507  auto i_obj = mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read); \
508  bytes_read += mutils::bytes_size(*i_obj); \
509  auto j_obj = mutils::from_bytes<std::decay_t<decltype(j)> >(dsm, buf + bytes_read); \
510  bytes_read += mutils::bytes_size(*j_obj); \
511  auto k_obj = mutils::from_bytes<std::decay_t<decltype(k)> >(dsm, buf + bytes_read); \
512  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj,*i_obj,*j_obj,*k_obj, *(mutils::from_bytes<std::decay_t<decltype(l)> >(dsm, buf + bytes_read + mutils::bytes_size(*k_obj)))); \
513  }
514 
515 #define DEFAULT_DESERIALIZE14(Name,a,b,c,d,e,f,g,h,i,j,k,l,m) \
516  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
517  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
518  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
519  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
520  bytes_read += mutils::bytes_size(*b_obj); \
521  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
522  bytes_read += mutils::bytes_size(*c_obj); \
523  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
524  bytes_read += mutils::bytes_size(*d_obj); \
525  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
526  bytes_read += mutils::bytes_size(*e_obj); \
527  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
528  bytes_read += mutils::bytes_size(*f_obj); \
529  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
530  bytes_read += mutils::bytes_size(*g_obj); \
531  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
532  bytes_read += mutils::bytes_size(*h_obj); \
533  auto i_obj = mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read); \
534  bytes_read += mutils::bytes_size(*i_obj); \
535  auto j_obj = mutils::from_bytes<std::decay_t<decltype(j)> >(dsm, buf + bytes_read); \
536  bytes_read += mutils::bytes_size(*j_obj); \
537  auto k_obj = mutils::from_bytes<std::decay_t<decltype(k)> >(dsm, buf + bytes_read); \
538  bytes_read += mutils::bytes_size(*k_obj); \
539  auto l_obj = mutils::from_bytes<std::decay_t<decltype(l)> >(dsm, buf + bytes_read); \
540  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj,*i_obj,*j_obj,*k_obj,*l_obj, *(mutils::from_bytes<std::decay_t<decltype(m)> >(dsm, buf + bytes_read + mutils::bytes_size(*l_obj)))); \
541  }
542 
543 #define DEFAULT_DESERIALIZE15(Name,a,b,c,d,e,f,g,h,i,j,k,l,m,n) \
544  static std::unique_ptr<Name> from_bytes(mutils::DeserializationManager* dsm, char const * buf){ \
545  auto a_obj = mutils::from_bytes<std::decay_t<decltype(a)> >(dsm, buf); \
546  std::size_t bytes_read = mutils::bytes_size(*a_obj); \
547  auto b_obj = mutils::from_bytes<std::decay_t<decltype(b)> >(dsm, buf + bytes_read); \
548  bytes_read += mutils::bytes_size(*b_obj); \
549  auto c_obj = mutils::from_bytes<std::decay_t<decltype(c)> >(dsm, buf + bytes_read); \
550  bytes_read += mutils::bytes_size(*c_obj); \
551  auto d_obj = mutils::from_bytes<std::decay_t<decltype(d)> >(dsm, buf + bytes_read); \
552  bytes_read += mutils::bytes_size(*d_obj); \
553  auto e_obj = mutils::from_bytes<std::decay_t<decltype(e)> >(dsm, buf + bytes_read); \
554  bytes_read += mutils::bytes_size(*e_obj); \
555  auto f_obj = mutils::from_bytes<std::decay_t<decltype(f)> >(dsm, buf + bytes_read); \
556  bytes_read += mutils::bytes_size(*f_obj); \
557  auto g_obj = mutils::from_bytes<std::decay_t<decltype(g)> >(dsm, buf + bytes_read); \
558  bytes_read += mutils::bytes_size(*g_obj); \
559  auto h_obj = mutils::from_bytes<std::decay_t<decltype(h)> >(dsm, buf + bytes_read); \
560  bytes_read += mutils::bytes_size(*h_obj); \
561  auto i_obj = mutils::from_bytes<std::decay_t<decltype(i)> >(dsm, buf + bytes_read); \
562  bytes_read += mutils::bytes_size(*i_obj); \
563  auto j_obj = mutils::from_bytes<std::decay_t<decltype(j)> >(dsm, buf + bytes_read); \
564  bytes_read += mutils::bytes_size(*j_obj); \
565  auto k_obj = mutils::from_bytes<std::decay_t<decltype(k)> >(dsm, buf + bytes_read); \
566  bytes_read += mutils::bytes_size(*k_obj); \
567  auto l_obj = mutils::from_bytes<std::decay_t<decltype(l)> >(dsm, buf + bytes_read); \
568  bytes_read += mutils::bytes_size(*l_obj); \
569  auto m_obj = mutils::from_bytes<std::decay_t<decltype(m)> >(dsm, buf + bytes_read); \
570  return std::make_unique<Name>(*a_obj,*b_obj,*c_obj,*d_obj,*e_obj,*f_obj,*g_obj,*h_obj,*i_obj,*j_obj,*k_obj,*l_obj,*m_obj, *(mutils::from_bytes<std::decay_t<decltype(n)> >(dsm, buf + bytes_read + mutils::bytes_size(*m_obj)))); \
571  }
572 
573 
574 #define DEFAULT_SERIALIZE_IMPL2(count, ...) DEFAULT_SERIALIZE ## count (__VA_ARGS__)
575 #define DEFAULT_SERIALIZE_IMPL(count, ...) DEFAULT_SERIALIZE_IMPL2(count, __VA_ARGS__)
576 #define DEFAULT_SERIALIZE(...) DEFAULT_SERIALIZE_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)
577 
578 
579 #define DEFAULT_DESERIALIZE_IMPL2(count, ...) DEFAULT_DESERIALIZE ## count (__VA_ARGS__)
580 #define DEFAULT_DESERIALIZE_IMPL(count, ...) DEFAULT_DESERIALIZE_IMPL2(count, __VA_ARGS__)
581 #define DEFAULT_DESERIALIZE(...) DEFAULT_DESERIALIZE_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)
582 
583 #define DEFAULT_DESERIALIZE_NOALLOC(Name)\
584  template<typename... SerializationMacroArgs>\
585  static mutils::context_ptr<Name> from_bytes_noalloc(SerializationMacroArgs&& ... args){ \
586  return mutils::context_ptr<Name>(Name::from_bytes(std::forward<SerializationMacroArgs>(args)...).release()); \
587  }\
588  template<typename... SerializationMacroArgs>\
589  static mutils::context_ptr<const Name> from_bytes_noalloc_const(SerializationMacroArgs&& ... args){ \
590  return mutils::context_ptr<const Name>(Name::from_bytes(std::forward<SerializationMacroArgs>(args)...).release()); \
591  }
592 
593 
609 #define DEFAULT_SERIALIZATION_SUPPORT(CLASS_NAME,CLASS_MEMBERS...) \
610  DEFAULT_SERIALIZE(CLASS_MEMBERS) DEFAULT_DESERIALIZE(CLASS_NAME,CLASS_MEMBERS) DEFAULT_DESERIALIZE_NOALLOC(CLASS_NAME) \
611  void ensure_registered(mutils::DeserializationManager&){}