factor STL container serialization

This commit is contained in:
moneromooo-monero 2017-12-22 19:47:12 +00:00
parent 7a9a4a6669
commit 2d17feb060
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
15 changed files with 279 additions and 223 deletions

View file

@ -63,15 +63,17 @@ struct is_blob_type { typedef boost::false_type type; };
template <class T>
struct has_free_serializer { typedef boost::true_type type; };
/*! \struct is_pair_type
/*! \struct is_basic_type
*
* \brief a descriptor for dispatching serialize
*/
template <class T>
struct is_pair_type { typedef boost::false_type type; };
struct is_basic_type { typedef boost::false_type type; };
template<typename F, typename S>
struct is_pair_type<std::pair<F,S>> { typedef boost::true_type type; };
struct is_basic_type<std::pair<F,S>> { typedef boost::true_type type; };
template<>
struct is_basic_type<std::string> { typedef boost::true_type type; };
/*! \struct serializer
*
@ -89,7 +91,7 @@ struct is_pair_type<std::pair<F,S>> { typedef boost::true_type type; };
template <class Archive, class T>
struct serializer{
static bool serialize(Archive &ar, T &v) {
return serialize(ar, v, typename boost::is_integral<T>::type(), typename is_blob_type<T>::type(), typename is_pair_type<T>::type());
return serialize(ar, v, typename boost::is_integral<T>::type(), typename is_blob_type<T>::type(), typename is_basic_type<T>::type());
}
template<typename A>
static bool serialize(Archive &ar, T &v, boost::false_type, boost::true_type, A a) {
@ -361,9 +363,3 @@ namespace serialization {
return r && check_stream_state(ar);
}
}
#include "string.h"
#include "vector.h"
#include "list.h"
#include "pair.h"
#include "set.h"