[857] | 1 | #ifndef BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
|
---|
| 2 | #define BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
|
---|
| 3 |
|
---|
| 4 | // MS compatible compilers support #pragma once
|
---|
| 5 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
---|
| 6 | # pragma once
|
---|
| 7 | #endif
|
---|
| 8 |
|
---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 10 | // collections_save_imp.hpp: serialization for stl collections
|
---|
| 11 |
|
---|
| 12 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
---|
| 13 | // Use, modification and distribution is subject to the Boost Software
|
---|
| 14 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 15 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 16 |
|
---|
| 17 | // See http://www.boost.org for updates, documentation, and revision history.
|
---|
| 18 |
|
---|
| 19 | // helper function templates for serialization of collections
|
---|
| 20 |
|
---|
| 21 | #include <boost/serialization/nvp.hpp>
|
---|
| 22 | #include <boost/serialization/serialization.hpp>
|
---|
| 23 |
|
---|
| 24 | namespace boost{
|
---|
| 25 | namespace serialization {
|
---|
| 26 | namespace stl {
|
---|
| 27 |
|
---|
| 28 | //////////////////////////////////////////////////////////////////////
|
---|
| 29 | // implementation of serialization for STL containers
|
---|
| 30 | //
|
---|
| 31 |
|
---|
| 32 | template<class Archive, class Container>
|
---|
| 33 | inline void save_collection(Archive & ar, const Container &s)
|
---|
| 34 | {
|
---|
| 35 | // record number of elements
|
---|
| 36 | unsigned int count = s.size();
|
---|
| 37 | ar << make_nvp("count", const_cast<const unsigned int &>(count));
|
---|
| 38 | BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
|
---|
| 39 | while(count-- > 0){
|
---|
| 40 | //if(0 == (ar.get_flags() & boost::archive::no_object_creation))
|
---|
| 41 | // note borland emits a no-op without the explicit namespace
|
---|
| 42 | boost::serialization::save_construct_data_adl(ar, &(*it), 0U);
|
---|
| 43 | ar << boost::serialization::make_nvp("item", *it++);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | } // namespace stl
|
---|
| 48 | } // namespace serialization
|
---|
| 49 | } // namespace boost
|
---|
| 50 |
|
---|
| 51 | #endif //BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
|
---|