6 #ifndef TURI_SERIALIZE_GL_VECTOR_HPP 7 #define TURI_SERIALIZE_GL_VECTOR_HPP 9 #include <core/storage/serialization/iarchive.hpp> 10 #include <core/storage/serialization/oarchive.hpp> 11 #include <core/storage/serialization/iterator.hpp> 15 template <
typename T>
class gl_vector;
17 namespace archive_detail {
22 template <
typename OutArcType,
typename ValueType,
bool IsPOD>
23 struct gl_vector_serialize_impl {
24 static void exec(OutArcType& oarc,
const ValueType& vec) {
27 BOOST_STATIC_ASSERT(
sizeof(OutArcType) == 0);
35 template <
typename InArcType,
typename ValueType,
bool IsPOD>
36 struct gl_vector_deserialize_impl {
37 static void exec(InArcType& iarc, ValueType& vec) {
40 BOOST_STATIC_ASSERT(
sizeof(InArcType) == 0);
46 template <
typename OutArcType,
typename ValueType>
47 struct gl_vector_serialize_impl<OutArcType, ValueType, false > {
48 static void exec(OutArcType& oarc,
const gl_vector<ValueType>& vec) {
49 oarc << size_t(vec.size());
50 for (
size_t i = 0;i < vec.size(); ++i) {
57 template <
typename OutArcType,
typename ValueType>
58 struct gl_vector_serialize_impl<OutArcType, ValueType, true > {
59 static void exec(OutArcType& oarc,
const gl_vector<ValueType>& vec) {
60 oarc << size_t(vec.size());
61 serialize(oarc, vec.data(),
sizeof(ValueType)*vec.size());
66 template <
typename InArcType,
typename ValueType>
67 struct gl_vector_deserialize_impl<InArcType, ValueType, false > {
68 static void exec(InArcType& iarc, gl_vector<ValueType>& vec){
71 vec.clear(); vec.resize(len);
72 for (
size_t i = 0;i < len; ++i) {
79 template <
typename InArcType,
typename ValueType>
80 struct gl_vector_deserialize_impl<InArcType, ValueType, true > {
81 static void exec(InArcType& iarc, gl_vector<ValueType>& vec){
84 vec.clear(); vec.resize(len);
85 deserialize(iarc, vec.data(),
sizeof(ValueType)*vec.size());
91 template <
typename OutArcType,
typename ValueType>
92 struct serialize_impl<OutArcType, gl_vector<ValueType>, false > {
93 static void exec(OutArcType& oarc,
const gl_vector<ValueType>& vec) {
94 gl_vector_serialize_impl<OutArcType, ValueType,
95 gl_is_pod_or_scaler<ValueType>::value >::exec(oarc, vec);
100 template <
typename InArcType,
typename ValueType>
101 struct deserialize_impl<InArcType, gl_vector<ValueType>, false > {
102 static void exec(InArcType& iarc, gl_vector<ValueType>& vec){
103 gl_vector_deserialize_impl<InArcType, ValueType,
104 gl_is_pod_or_scaler<ValueType>::value >::exec(iarc, vec);