Turi Create  4.0
list.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_SERIALIZE_LIST_HPP
7 #define TURI_SERIALIZE_LIST_HPP
8 
9 #include <list>
10 
11 #include <core/storage/serialization/iarchive.hpp>
12 #include <core/storage/serialization/oarchive.hpp>
13 #include <core/storage/serialization/iterator.hpp>
14 
15 
16 namespace turi {
17 namespace archive_detail {
18  /** serializes a list */
19  template <typename OutArcType, typename T>
20  struct serialize_impl<OutArcType, std::list<T>, false > {
21  static void exec(OutArcType& oarc, const std::list<T>& vec){
22  serialize_iterator(oarc,vec.begin(),vec.end(), vec.size());
23  }
24  };
25 
26  /** deserializes a list */
27  template <typename InArcType, typename T>
28  struct deserialize_impl<InArcType, std::list<T>, false > {
29  static void exec(InArcType& iarc, std::list<T>& vec){
30  vec.clear();
31  deserialize_iterator<InArcType, T>(iarc, std::inserter(vec,vec.end()));
32  }
33  };
34 } // archive_detail
35 } // turicreate
36 #endif
STL namespace.
void serialize_iterator(OutArcType &oarc, RandomAccessIterator begin, RandomAccessIterator end)
Serializes the contents between the iterators begin and end.
Definition: iterator.hpp:36