summaryrefslogtreecommitdiff
path: root/boost/serialization/collections_load_imp.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:30:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:32:57 +0900
commit71d216b90256936a9638f325af9bc69d720e75de (patch)
tree9c5f682d341c7c88ad0c8e3d4b262e00b6fb691a /boost/serialization/collections_load_imp.hpp
parent733b5d5ae2c5d625211e2985ac25728ac3f54883 (diff)
downloadboost-71d216b90256936a9638f325af9bc69d720e75de.tar.gz
boost-71d216b90256936a9638f325af9bc69d720e75de.tar.bz2
boost-71d216b90256936a9638f325af9bc69d720e75de.zip
Imported Upstream version 1.59.0
Change-Id: I2dde00f4eca71df3eea9d251dcaecde18a6c90a5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/serialization/collections_load_imp.hpp')
-rw-r--r--boost/serialization/collections_load_imp.hpp153
1 files changed, 46 insertions, 107 deletions
diff --git a/boost/serialization/collections_load_imp.hpp b/boost/serialization/collections_load_imp.hpp
index 2291e74226..246b64ed65 100644
--- a/boost/serialization/collections_load_imp.hpp
+++ b/boost/serialization/collections_load_imp.hpp
@@ -38,6 +38,8 @@ namespace std{
#include <boost/serialization/detail/stack_constructor.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/item_version_type.hpp>
+#include <boost/serialization/detail/is_default_constructible.hpp>
+#include <boost/utility/enable_if.hpp>
namespace boost{
namespace serialization {
@@ -47,116 +49,53 @@ namespace stl {
// implementation of serialization for STL containers
//
-// sequential container input
-template<class Archive, class Container>
-struct archive_input_seq
-{
- inline typename Container::iterator
- operator()(
- Archive &ar,
- Container &s,
- const unsigned int v,
- typename Container::iterator hint
- ){
- typedef typename Container::value_type type;
- detail::stack_construct<Archive, type> t(ar, v);
- // borland fails silently w/o full namespace
- ar >> boost::serialization::make_nvp("item", t.reference());
- s.push_back(t.reference());
- ar.reset_object_address(& s.back() , & t.reference());
- return hint;
- }
-};
-
-// map input
-template<class Archive, class Container>
-struct archive_input_map
-{
- inline typename Container::iterator
- operator()(
- Archive &ar,
- Container &s,
- const unsigned int v,
- typename Container::iterator hint
- ){
- typedef typename Container::value_type type;
- detail::stack_construct<Archive, type> t(ar, v);
- // borland fails silently w/o full namespace
- ar >> boost::serialization::make_nvp("item", t.reference());
- typename Container::iterator result =
- s.insert(hint, t.reference());
- // note: the following presumes that the map::value_type was NOT tracked
- // in the archive. This is the usual case, but here there is no way
- // to determine that.
- ar.reset_object_address(
- & (result->second),
- & t.reference().second
- );
- return result;
- }
-};
-
-// set input
-template<class Archive, class Container>
-struct archive_input_set
-{
- inline typename Container::iterator
- operator()(
- Archive &ar,
- Container &s,
- const unsigned int v,
- typename Container::iterator hint
- ){
- typedef typename Container::value_type type;
- detail::stack_construct<Archive, type> t(ar, v);
- // borland fails silently w/o full namespace
- ar >> boost::serialization::make_nvp("item", t.reference());
- typename Container::iterator result =
- s.insert(hint, t.reference());
- ar.reset_object_address(& (* result), & t.reference());
- return result;
- }
-};
-
-template<class Container>
-class reserve_imp
-{
-public:
- void operator()(Container &s, std::size_t count) const {
- s.reserve(count);
- }
-};
-
-template<class Container>
-class no_reserve_imp
-{
-public:
- void operator()(Container & /* s */, std::size_t /* count */) const{}
-};
-
-template<class Archive, class Container, class InputFunction, class R>
-inline void load_collection(Archive & ar, Container &s)
-{
- s.clear();
- const boost::archive::library_version_type library_version(
- ar.get_library_version()
- );
- // retrieve number of elements
- item_version_type item_version(0);
- collection_size_type count;
- ar >> BOOST_SERIALIZATION_NVP(count);
- if(boost::archive::library_version_type(3) < library_version){
- ar >> BOOST_SERIALIZATION_NVP(item_version);
+template<
+ class Archive,
+ class T
+>
+typename boost::enable_if<
+ typename detail::is_default_constructible<
+ typename T::value_type
+ >,
+ void
+>::type
+collection_load_impl(
+ Archive & ar,
+ T & t,
+ collection_size_type count,
+ item_version_type item_version
+){
+ t.resize(count);
+ typename T::iterator hint;
+ hint = t.begin();
+ while(count-- > 0){
+ ar >> boost::serialization::make_nvp("item", *hint++);
}
+}
- R rx;
- rx(s, count);
- InputFunction ifunc;
- typename Container::iterator hint;
- hint = s.begin();
+template<
+ class Archive,
+ class T
+>
+typename boost::disable_if<
+ typename detail::is_default_constructible<
+ typename T::value_type
+ >,
+ void
+>::type
+collection_load_impl(
+ Archive & ar,
+ T & t,
+ collection_size_type count,
+ item_version_type item_version
+){
+ t.clear();
while(count-- > 0){
- hint = ifunc(ar, s, item_version, hint);
- }
+ detail::stack_construct<Archive, typename T::value_type> u(ar, item_version);
+ ar >> boost::serialization::make_nvp("item", u.reference());
+ t.push_back(u.reference());
+ ar.reset_object_address(& t.back() , & u.reference());
+ }
}
} // namespace stl