Main Page · Modules · All Classes · Class Hierarchy
MPDataContainerHelpers.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include <MCDefs.hpp>
25 
26 #include <qvector.h>
27 
28 #include <boost/serialization/collections_load_imp.hpp>
29 
35 namespace boost
36 {
37 namespace serialization
38 {
39 
41 template <class Archive, class U>
42 inline void save(Archive& archive, const QVector<U>& vector, const uint version)
43 {
44  MC_UNUSED(version);
45  boost::serialization::stl::save_collection< Archive, QVector<U> >(archive, vector);
46 }
47 
49 template <class Archive, class U>
50 inline void load(Archive& archive, QVector<U>& vector, const uint version)
51 {
52  MC_UNUSED(version);
53  boost::serialization::stl::load_collection<
54  Archive,
55  QVector<U>,
56  boost::serialization::stl::archive_input_seq<Archive, QVector<U> >,
57  boost::serialization::stl::no_reserve_imp< QVector<U> > >(archive, vector);
58 }
59 
60 template<class Archive, class U >
61 inline void serialize(Archive& archive, QVector<U>& vector, const uint version)
62 {
63  boost::serialization::split_free(archive, vector, version);
64 }
65 
66 
68 template <class Archive, class U>
69 inline void save(Archive& archive, const QVector<QVector<U> >& table, const uint version)
70 {
71  MC_UNUSED(version);
72  unsigned int count = table.count();
73 
74  archive << boost::serialization::make_nvp("count", count);
75 
76  for (unsigned int i = 0; i < count; ++i)
77  archive << boost::serialization::make_nvp("vector", table.at(i));
78 }
79 
81 template <class Archive, class U>
82 inline void load(Archive& archive, QVector<QVector<U> >& table, const uint version)
83 {
84  MC_UNUSED(version);
85  unsigned int count = 0;
86 
87  archive >> boost::serialization::make_nvp("count", count);
88 
89  table.clear();
90  table.reserve(count);
91  QVector<U> vector;
92 
93  for (unsigned int i = 0; i < count; ++i)
94  {
95  archive >> boost::serialization::make_nvp("vector", vector);
96  table.append(vector);
97  }
98 }
99 
100 template<class Archive, class U >
101 inline void serialize(Archive& archive, QVector<QVector<U> >& table, const uint version)
102 {
103  boost::serialization::split_free(archive, table, version);
104 }
105 
106 }
107 }
108 
109 BOOST_SERIALIZATION_COLLECTION_TRAITS(QVector)
110 
111 
#define MC_UNUSED(a)
Helper macro to avoid compiler warning about unused function parameters.
Definition: MCDefs.hpp:601