openMSX
serialize_core.hh
Go to the documentation of this file.
1 #ifndef SERIALIZE_CORE_HH
2 #define SERIALIZE_CORE_HH
3 
4 #include "serialize_constr.hh"
5 #include "serialize_meta.hh"
6 #include "unreachable.hh"
7 #include <string>
8 #include <type_traits>
9 #include <cassert>
10 #include <memory>
11 
12 namespace openmsx {
13 
14 // Type-queries for serialization framework
15 // is_primitive<T>
16 template<typename T> struct is_primitive : std::false_type {};
17 template<> struct is_primitive<bool> : std::true_type {};
18 template<> struct is_primitive<char> : std::true_type {};
19 template<> struct is_primitive<signed char> : std::true_type {};
20 template<> struct is_primitive<signed short> : std::true_type {};
21 template<> struct is_primitive<signed int> : std::true_type {};
22 template<> struct is_primitive<signed long> : std::true_type {};
23 template<> struct is_primitive<unsigned char> : std::true_type {};
24 template<> struct is_primitive<unsigned short> : std::true_type {};
25 template<> struct is_primitive<unsigned int> : std::true_type {};
26 template<> struct is_primitive<unsigned long> : std::true_type {};
27 template<> struct is_primitive<float> : std::true_type {};
28 template<> struct is_primitive<double> : std::true_type {};
29 template<> struct is_primitive<long double> : std::true_type {};
30 template<> struct is_primitive<long long> : std::true_type {};
31 template<> struct is_primitive<unsigned long long> : std::true_type {};
32 template<> struct is_primitive<std::string> : std::true_type {};
33 
34 
35 
36 // Normally to make a class serializable, you have to implement a serialize()
37 // method on the class. For some classes we cannot extend the source code. So
38 // we need an alternative, non-intrusive, way to make those classes
39 // serializable.
40 template <typename Archive, typename T>
41 void serialize(Archive& ar, T& t, unsigned version)
42 {
43  // By default use the serialize() member. But this function can
44  // be overloaded to serialize classes in a non-intrusive way.
45  t.serialize(ar, version);
46 }
47 
48 template <typename Archive, typename T1, typename T2>
49 void serialize(Archive& ar, std::pair<T1, T2>& p, unsigned /*version*/)
50 {
51  ar.serialize("first", p.first);
52  ar.serialize("second", p.second);
53 }
54 template<typename T1, typename T2> struct SerializeClassVersion<std::pair<T1, T2>>
55 {
56  static const unsigned value = 0;
57 };
58 
60 
97 template<typename T> struct serialize_as_enum : std::false_type {};
98 
99 template<typename T> struct enum_string {
100  const char* str;
101  T e;
102 };
103 void enumError(const std::string& str);
104 template<typename T> struct serialize_as_enum_impl : std::true_type {
105  serialize_as_enum_impl(std::initializer_list<enum_string<T>> info_) : info(info_) {}
106  std::string toString(T t) const {
107  for (auto& i : info) {
108  if (i.e == t) return i.str;
109  }
110  assert(false);
111  return "internal-error-unknown-enum-value";
112  }
113  T fromString(const std::string& str) const {
114  for (auto& i : info) {
115  if (i.str == str) return i.e;
116  }
117  enumError(str); // does not return (throws)
118  return T(); // avoid warning
119  }
120 private:
121  std::initializer_list<enum_string<T>> info;
122 };
123 
124 #define SERIALIZE_ENUM(TYPE,INFO) \
125 template<> struct serialize_as_enum< TYPE > : serialize_as_enum_impl< TYPE > { \
126  serialize_as_enum() : serialize_as_enum_impl< TYPE >( INFO ) {} \
127 };
128 
130 
131 // serialize_as_pointer<T>
132 //
133 // Type-trait class that indicates whether a certain type should be serialized
134 // as a pointer or not. There can be multiple pointers to the same object,
135 // only the first such pointer is actually stored, the others are stored as
136 // a reference to this first object.
137 //
138 // By default all pointer types are treated as pointer, but also smart pointer
139 // can be traited as such. Though only unique_ptr<T> is implemented ATM.
140 //
141 // The serialize_as_pointer class has the following members:
142 // - static bool value
143 // True iff this type must be serialized as a pointer.
144 // The fields below are only valid (even only present) if this variable
145 // is true.
146 // - using type = T
147 // The pointed-to type
148 // - T* getPointer(X x)
149 // Get an actual pointer from the abstract pointer x
150 // (X can be a smart pointer type)
151 // - void setPointer(X x, T* p, Archive& ar)
152 // Copy the raw-pointer p to the abstract pointer x
153 // The archive can be used to store per-archive data, this is for example
154 // needed for shared_ptr.
155 
156 template<typename T> struct serialize_as_pointer : std::false_type {};
157 template<typename T> struct serialize_as_pointer_impl : std::true_type
158 {
159  // pointer to primitive types not supported
160  static_assert(!is_primitive<T>::value,
161  "can't serialize ptr to primitive type");
162  using type = T;
163 };
164 template<typename T> struct serialize_as_pointer<T*>
166 {
167  static inline T* getPointer(T* t) { return t; }
168  template<typename Archive>
169  static inline void setPointer(T*& t, T* p, Archive& /*ar*/) {
170  t = p;
171  }
172 };
173 template<typename T> struct serialize_as_pointer<std::unique_ptr<T>>
175 {
176  static inline T* getPointer(const std::unique_ptr<T>& t) { return t.get(); }
177  template<typename Archive>
178  static inline void setPointer(std::unique_ptr<T>& t, T* p, Archive& /*ar*/) {
179  t.reset(p);
180  }
181 };
182 template<typename T> struct serialize_as_pointer<std::shared_ptr<T>>
184 {
185  static T* getPointer(const std::shared_ptr<T>& t) { return t.get(); }
186  template<typename Archive>
187  static void setPointer(std::shared_ptr<T>& t, T* p, Archive& ar) {
188  ar.resetSharedPtr(t, p);
189  }
190 };
191 
193 
194 // serialize_as_collection<T>
195 //
196 // Type-trait class that indicates whether a certain type should be serialized
197 // as a collection or not. The serialization code 'knows' how to serialize
198 // collections, so as a user of the serializer you only need to list the
199 // collection to have it serialized (you don't have to iterate over it
200 // manually).
201 //
202 // By default arrays, std::vector, std::list, std::set, std::deque and std::map
203 // are recognized as collections. Though for STL collections you need to add
204 // #include "serialize_stl.hh"
205 //
206 // The serialize_as_collection class has the following members:
207 //
208 // - static bool value
209 // True iff this type must be serialized as a collection.
210 // The fields below are only valid (even only present) if this variable
211 // is true.
212 // - int size
213 // The size of the collection, -1 for variable sized collections.
214 // Fixed sized collections can be serialized slightly more efficient
215 // becuase we don't need to explicitly store the size.
216 // - using value_type = ...
217 // The type stored in the collection (only homogeneous collections are
218 // supported).
219 // - bool loadInPlace
220 // Indicates whether we can directly load the elements in the correct
221 // position in the container, otherwise there will be an extra assignment.
222 // For this to be possible, the output iterator must support a dereference
223 // operator that returns a 'regular' value_type.
224 // - using const_iterator = ...
225 // - const_iterator begin(...)
226 // - const_iterator end(...)
227 // Returns begin/end iterator for the given collection. Used for saving.
228 // - using output_iterator = ...
229 // - void prepare(..., int n)
230 // - output_iterator output(...)
231 // These are used for loading. The prepare() method should prepare the
232 // collection to receive 'n' elements. The output() method returns an
233 // output_iterator to the beginning of the collection.
234 
235 template<typename T> struct serialize_as_collection : std::false_type {};
236 template<typename T, int N> struct serialize_as_collection<T[N]> : std::true_type
237 {
238  static const int size = N; // fixed size
239  using value_type = T;
240  // save
241  using const_iterator = const T*;
242  static const T* begin(const T (&array)[N]) { return &array[0]; }
243  static const T* end (const T (&array)[N]) { return &array[N]; }
244  // load
245  static const bool loadInPlace = true;
246  using output_iterator = T*;
247  static void prepare(T (&/*array*/)[N], int /*n*/) { }
248  static T* output(T (&array)[N]) { return &array[0]; }
249 };
250 
252 
253 // Implementation of the different save-strategies.
254 //
255 // ATM we have
256 // - PrimitiveSaver
257 // Saves primitive values: int, bool, string, ...
258 // Primitive values cannot be versioned.
259 // - EnumSaver
260 // Depending on the archive type, enums are either saved as strings (XML
261 // archive) or as integers (memory archive).
262 // This does not work automatically: it needs a specialization of
263 // serialize_as_enum, see above.
264 // - ClassSaver
265 // From a serialization POV classes are a (heterogeneous) collection of
266 // other to-be-serialized items.
267 // Classes can have a version number, this allows to evolve the class
268 // structure while still being able to load older versions (the load
269 // method receive the version number as parameter, the user still needs
270 // to keep the old loading code in place).
271 // Optionally the name of the (concrete) class is saved in the stream.
272 // This is used to support loading of polymorphic classes.
273 // There is also an (optional) id saved in the stream. This used to
274 // resolve possible multiple pointers to the same class.
275 // - PointerSaver
276 // Saves a pointer to a class (pointers to primitive types are not
277 // supported). See also serialize_as_pointer
278 // - IDSaver
279 // Weaker version of PointerSaver: it can only save pointers to objects
280 // that are already saved before (so it's will be saved by storing a
281 // reference). To only reason to use IDSaver (iso PointerSaver) is that
282 // it will not instantiate the object construction code.
283 // - CollectionSaver
284 // Saves a whole collection. See also serialize_as_collection
285 //
286 // All these strategies have a method:
287 // template<typename Archive> void operator()(Archive& ar, const T& t)
288 // 'ar' is archive where the serialized stream will go
289 // 't' is the to-be-saved object
290 // 'saveId' Should ID be saved
291 
292 template<typename T> struct PrimitiveSaver
293 {
294  template<typename Archive> void operator()(Archive& ar, const T& t,
295  bool /*saveId*/)
296  {
297  static_assert(is_primitive<T>::value, "must be primitive type");
298  ar.save(t);
299  }
300 };
301 template<typename T> struct EnumSaver
302 {
303  template<typename Archive> void operator()(Archive& ar, const T& t,
304  bool /*saveId*/)
305  {
306  if (ar.translateEnumToString()) {
308  std::string str = sae.toString(t);
309  ar.save(str);
310  } else {
311  ar.save(int(t));
312  }
313  }
314 };
315 template<typename T> struct ClassSaver
316 {
317  template<typename Archive> void operator()(
318  Archive& ar, const T& t, bool saveId,
319  const char* type = nullptr, bool saveConstrArgs = false)
320  {
321  // Order is important (for non-xml archives). We use this order:
322  // - id
323  // - type
324  // - version
325  // - constructor args
326  // Rational:
327  // - 'id' must be first: it could be nullptr, in that
328  // case the other fields are not even present.
329  // - 'type' must be before version, because for some types we
330  // might not need to store version (though it's unlikely)
331  // - version must be before constructor args because the
332  // constr args depend on the version
333  if (saveId) {
334  unsigned id = ar.generateId(&t);
335  ar.attribute("id", id);
336  }
337 
338  if (type) {
339  ar.attribute("type", type);
340  }
341 
342  unsigned version = SerializeClassVersion<T>::value;
343  if ((version != 0) && ar.needVersion()) {
344  if (!ar.canHaveOptionalAttributes() ||
345  (version != 1)) {
346  ar.attribute("version", version);
347  }
348  }
349 
350  if (saveConstrArgs) {
351  // save local constructor args (if any)
352  SerializeConstructorArgs<T> constrArgs;
353  constrArgs.save(ar, t);
354  }
355 
356  using TNC = typename std::remove_const<T>::type;
357  auto& t2 = const_cast<TNC&>(t);
358  serialize(ar, t2, version);
359  }
360 };
361 template<typename TP> struct PointerSaver
362 {
363  // note: we only support pointer to class
364  template<typename Archive> void operator()(Archive& ar, const TP& tp2,
365  bool /*saveId*/)
366  {
367  static_assert(serialize_as_pointer<TP>::value,
368  "must be serialized as pointer");
369  using T = typename serialize_as_pointer<TP>::type;
370  const T* tp = serialize_as_pointer<TP>::getPointer(tp2);
371  if (!tp) {
372  unsigned id = 0;
373  ar.attribute("id_ref", id);
374  return;
375  }
376  if (unsigned id = ar.getId(tp)) {
377  ar.attribute("id_ref", id);
378  } else {
379  if (std::is_polymorphic<T>::value) {
381  } else {
382  ClassSaver<T> saver;
383  // don't store type
384  // store id, constr-args
385  saver(ar, *tp, true, nullptr, true);
386  }
387  }
388  }
389 };
390 template<typename TP> struct IDSaver
391 {
392  template<typename Archive> void operator()(Archive& ar, const TP& tp2)
393  {
394  static_assert(serialize_as_pointer<TP>::value,
395  "must be serialized as pointer");
397  unsigned id;
398  if (!tp) {
399  id = 0;
400  } else {
401  id = ar.getId(tp);
402  assert(id);
403  }
404  ar.attribute("id_ref", id);
405  }
406 };
407 template<typename TC> struct CollectionSaver
408 {
409  template<typename Archive> void operator()(Archive& ar, const TC& tc,
410  bool saveId)
411  {
412  using sac = serialize_as_collection<TC>;
413  static_assert(sac::value, "must be serialized as collection");
414  auto begin = sac::begin(tc);
415  auto end = sac::end (tc);
416  if ((sac::size < 0) && (!ar.canCountChildren())) {
417  // variable size
418  // e.g. in an XML archive the loader can look-ahead and
419  // count the number of sub-tags, so no need to
420  // explicitly store the size for such archives.
421  int n = int(std::distance(begin, end));
422  ar.serialize("size", n);
423  }
424  for (; begin != end; ++begin) {
425  if (saveId) {
426  ar.serializeWithID("item", *begin);
427  } else {
428  ar.serialize("item", *begin);
429  }
430  }
431  }
432 };
433 
434 // Delegate to a specific Saver class
435 // (implemented as inheriting from a specific baseclass).
436 template<typename T> struct Saver
437  : if_<is_primitive<T>,
438  PrimitiveSaver<T>,
439  if_<serialize_as_enum<T>,
440  EnumSaver<T>,
441  if_<serialize_as_pointer<T>,
442  PointerSaver<T>,
443  if_<serialize_as_collection<T>,
444  CollectionSaver<T>,
445  ClassSaver<T>>>>> {};
446 
448 
449 // Implementation of the different load-strategies.
450 //
451 // This matches very closly with the save-strategies above.
452 //
453 // All these strategies have a method:
454 // template<typename Archive, typename TUPLE>
455 // void operator()(Archive& ar, const T& t, TUPLE args)
456 // 'ar' Is archive where the serialized stream will go
457 // 't' Is the object that has to be restored.
458 // In case of a class (not a pointer to a class) the actual object
459 // is already constructed, but it still needs to be filled in with
460 // the correct data.
461 // 'args' (Only used by PointerLoader) holds extra parameters used
462 // to construct objects.
463 // 'id' Used to skip loading an ID, see comment in ClassLoader
464 
465 template<typename T> struct PrimitiveLoader
466 {
467  template<typename Archive, typename TUPLE>
468  void operator()(Archive& ar, T& t, TUPLE /*args*/, int /*id*/)
469  {
470  static_assert(std::tuple_size<TUPLE>::value == 0,
471  "can't have constructor arguments");
472  ar.load(t);
473  }
474 };
475 template<typename T> struct EnumLoader
476 {
477  template<typename Archive, typename TUPLE>
478  void operator()(Archive& ar, T& t, TUPLE /*args*/, int /*id*/)
479  {
480  static_assert(std::tuple_size<TUPLE>::value == 0,
481  "can't have constructor arguments");
482  if (ar.translateEnumToString()) {
483  std::string str;
484  ar.load(str);
486  t = sae.fromString(str);
487  } else {
488  int i;
489  ar.load(i);
490  t = T(i);
491  }
492  }
493 };
494 
495 unsigned loadVersionHelper(MemInputArchive& ar, const char* className,
496  unsigned latestVersion);
497 unsigned loadVersionHelper(XmlInputArchive& ar, const char* className,
498  unsigned latestVersion);
499 template<typename T, typename Archive> unsigned loadVersion(Archive& ar)
500 {
501  unsigned latestVersion = SerializeClassVersion<T>::value;
502  if ((latestVersion != 0) && ar.needVersion()) {
503  return loadVersionHelper(ar, typeid(T).name(), latestVersion);
504  } else {
505  return latestVersion;
506  }
507 }
508 template<typename T> struct ClassLoader
509 {
510  template<typename Archive, typename TUPLE>
511  void operator()(Archive& ar, T& t, TUPLE /*args*/, int id = 0,
512  int version = -1)
513  {
514  static_assert(std::tuple_size<TUPLE>::value == 0,
515  "can't have constructor arguments");
516 
517  // id == -1: don't load id, don't addPointer
518  // id == 0: load id from archive, addPointer
519  // id == N: id already loaded, still addPointer
520  if (id != -1) {
521  if (id == 0) {
522  ar.attribute("id", id);
523  }
524  ar.addPointer(id, &t);
525  }
526 
527  // version == -1: load version
528  // version == N: version already loaded
529  if (version == -1) {
530  version = loadVersion<T>(ar);
531  }
532 
533  using TNC = typename std::remove_const<T>::type;
534  auto& t2 = const_cast<TNC&>(t);
535  serialize(ar, t2, version);
536  }
537 };
538 template<typename T> struct NonPolymorphicPointerLoader
539 {
540  template<typename Archive, typename GlobalTuple>
541  T* operator()(Archive& ar, unsigned id, GlobalTuple globalArgs)
542  {
543  int version = loadVersion<T>(ar);
544 
545  // load (local) constructor args (if any)
546  using TNC = typename std::remove_const<T>::type;
547  using ConstrArgs = SerializeConstructorArgs<TNC>;
548  ConstrArgs constrArgs;
549  auto localArgs = constrArgs.load(ar, version);
550 
551  // combine global and local constr args
552  auto args = std::tuple_cat(globalArgs, localArgs);
553  // TODO make combining global/local constr args configurable
554 
555  Creator<T> creator;
556  auto tp = creator(args);
557  ClassLoader<T> loader;
558  loader(ar, *tp, std::make_tuple(), id, version);
559  return tp.release();
560  }
561 };
562 template<typename T> struct PolymorphicPointerLoader
563 {
564  template<typename Archive, typename TUPLE>
565  T* operator()(Archive& ar, unsigned id, TUPLE args)
566  {
567  using ArgsType = typename PolymorphicConstructorArgs<T>::type;
568  static_assert(std::is_same<TUPLE, ArgsType>::value,
569  "constructor arguments types must match");
570  return static_cast<T*>(
572  }
573 };
574 template<typename T> struct PointerLoader2
575  // extra indirection needed because inlining the body of
576  // NonPolymorphicPointerLoader in PointerLoader does not compile
577  // for abstract types
578  : if_<std::is_polymorphic<T>, PolymorphicPointerLoader<T>,
579  NonPolymorphicPointerLoader<T>> {};
580 
581 template<typename TP> struct PointerLoader
582 {
583  template<typename Archive, typename GlobalTuple>
584  void operator()(Archive& ar, TP& tp2, GlobalTuple globalArgs, int /*id*/)
585  {
586  static_assert(serialize_as_pointer<TP>::value,
587  "must be serialized as a pointer");
588  // in XML archives we use 'id_ref' or 'id', in other archives
589  // we don't care about the name
590  unsigned id;
591  if (ar.canHaveOptionalAttributes() &&
592  ar.findAttribute("id_ref", id)) {
593  // nothing, 'id' already filled in
594  } else {
595  ar.attribute("id", id);
596  }
597 
598  using T = typename serialize_as_pointer<TP>::type;
599  T* tp;
600  if (id == 0) {
601  tp = nullptr;
602  } else {
603  if (void* p = ar.getPointer(id)) {
604  tp = static_cast<T*>(p);
605  } else {
606  PointerLoader2<T> loader;
607  tp = loader(ar, id, globalArgs);
608  }
609  }
611  }
612 };
613 void pointerError(unsigned id);
614 template<typename TP> struct IDLoader
615 {
616  template<typename Archive>
617  void operator()(Archive& ar, TP& tp2)
618  {
619  static_assert(serialize_as_pointer<TP>::value,
620  "must be serialized as a pointer");
621  unsigned id;
622  ar.attribute("id_ref", id);
623 
624  using T = typename serialize_as_pointer<TP>::type;
625  T* tp;
626  if (id == 0) {
627  tp = nullptr;
628  } else {
629  void* p = ar.getPointer(id);
630  if (!p) {
631  pointerError(id);
632  }
633  tp = static_cast<T*>(p);
634  }
636  }
637 };
638 
639 template<typename sac, bool IN_PLACE = sac::loadInPlace> struct CollectionLoaderHelper;
640 template<typename sac> struct CollectionLoaderHelper<sac, true>
641 {
642  // used for array and vector
643  template<typename Archive, typename TUPLE, typename OUT_ITER>
644  void operator()(Archive& ar, TUPLE args, OUT_ITER it, int id)
645  {
646  ar.doSerialize("item", *it, args, id);
647  }
648 };
649 template<typename sac> struct CollectionLoaderHelper<sac, false>
650 {
651  // We can't directly load the element in the correct position:
652  // This screws-up id/pointer management because the element is still
653  // copied after construction (and pointer value of initial object is
654  // stored).
655  template<typename Archive, typename TUPLE, typename OUT_ITER>
656  void operator()(Archive& ar, TUPLE args, OUT_ITER it, int id)
657  {
658  typename sac::value_type elem;
659  ar.doSerialize("item", elem, args, id);
660  *it = std::move(elem);
661  }
662 };
663 template<typename TC> struct CollectionLoader
664 {
665  template<typename Archive, typename TUPLE>
666  void operator()(Archive& ar, TC& tc, TUPLE args, int id = 0)
667  {
668  assert((id == 0) || (id == -1));
669  using sac = serialize_as_collection<TC>;
670  static_assert(sac::value, "must be serialized as a collection");
671  int n = sac::size;
672  if (n < 0) {
673  // variable size
674  if (ar.canCountChildren()) {
675  n = ar.countChildren();
676  } else {
677  ar.serialize("size", n);
678  }
679  }
680  sac::prepare(tc, n);
681  auto it = sac::output(tc);
682  CollectionLoaderHelper<sac> loadOneElement;
683  for (int i = 0; i < n; ++i, ++it) {
684  loadOneElement(ar, args, it, id);
685  }
686  }
687 };
688 template<typename T> struct Loader
689  : if_<is_primitive<T>,
690  PrimitiveLoader<T>,
691  if_<serialize_as_enum<T>,
692  EnumLoader<T>,
693  if_<serialize_as_pointer<T>,
694  PointerLoader<T>,
695  if_<serialize_as_collection<T>,
696  CollectionLoader<T>,
697  ClassLoader<T>>>>> {};
698 
699 } // namespace openmsx
700 
701 #endif
static T * getPointer(const std::unique_ptr< T > &t)
string_ref::const_iterator end(const string_ref &x)
Definition: string_ref.hh:167
void operator()(Archive &ar, T &t, TUPLE, int id=0, int version=-1)
static const T * begin(const T(&array)[N])
void operator()(Archive &ar, TP &tp2)
void pointerError(unsigned id)
void operator()(Archive &ar, const T &t, bool saveId, const char *type=nullptr, bool saveConstrArgs=false)
STL namespace.
Store association between polymorphic class (base- or subclass) and the list of constructor arguments...
Utility to do T* t = new T(...)
void operator()(Archive &ar, T &t, TUPLE, int)
void operator()(Archive &ar, TUPLE args, OUT_ITER it, int id)
void operator()(Archive &ar, TP &tp2, GlobalTuple globalArgs, int)
void save(Archive &, const T &)
std::string toString(T t) const
unsigned loadVersionHelper(MemInputArchive &, const char *, unsigned)
void operator()(Archive &ar, const TC &tc, bool saveId)
void operator()(Archive &ar, const T &t, bool)
type load(Archive &, unsigned)
static const unsigned value
static void * load(Archive &ar, unsigned id, const void *args)
void operator()(Archive &ar, const TP &tp2, bool)
T * operator()(Archive &ar, unsigned id, TUPLE args)
unsigned loadVersion(Archive &ar)
static void setPointer(std::shared_ptr< T > &t, T *p, Archive &ar)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void enumError(const std::string &str)
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
serialize_as_enum_impl(std::initializer_list< enum_string< T >> info_)
T * operator()(Archive &ar, unsigned id, GlobalTuple globalArgs)
void operator()(Archive &ar, T &t, TUPLE, int)
static void setPointer(T *&t, T *p, Archive &)
void operator()(Archive &ar, TC &tc, TUPLE args, int id=0)
T fromString(const std::string &str) const
static void setPointer(std::unique_ptr< T > &t, T *p, Archive &)
size_t size() const
Store serialization-version number of a class.
Definition: serialize.hh:23
void operator()(Archive &ar, const TP &tp2)
Serialize (local) constructor arguments.
string_ref::const_iterator begin(const string_ref &x)
Definition: string_ref.hh:166
void operator()(Archive &ar, TUPLE args, OUT_ITER it, int id)
static T * getPointer(const std::shared_ptr< T > &t)
void serialize(Archive &ar, T &t, unsigned version)
void operator()(Archive &ar, const T &t, bool)
static void save(Archive &ar, T *t)
static const T * end(const T(&array)[N])