annotate DEPENDENCIES/generic/include/boost/flyweight/serialize.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 /* Copyright 2006-2014 Joaquin M Lopez Munoz.
Chris@102 2 * Distributed under the Boost Software License, Version 1.0.
Chris@102 3 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 4 * http://www.boost.org/LICENSE_1_0.txt)
Chris@102 5 *
Chris@102 6 * See http://www.boost.org/libs/flyweight for library home page.
Chris@102 7 */
Chris@102 8
Chris@102 9 #ifndef BOOST_FLYWEIGHT_SERIALIZE_HPP
Chris@102 10 #define BOOST_FLYWEIGHT_SERIALIZE_HPP
Chris@102 11
Chris@102 12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
Chris@102 13 #pragma once
Chris@102 14 #endif
Chris@102 15
Chris@102 16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
Chris@102 17 #include <boost/flyweight/flyweight_fwd.hpp>
Chris@102 18 #include <boost/flyweight/detail/archive_constructed.hpp>
Chris@102 19 #include <boost/flyweight/detail/serialization_helper.hpp>
Chris@102 20 #include <boost/serialization/nvp.hpp>
Chris@102 21 #include <boost/serialization/split_free.hpp>
Chris@102 22 #include <boost/throw_exception.hpp>
Chris@102 23 #include <memory>
Chris@102 24
Chris@102 25 /* Serialization routines for flyweight<T>.
Chris@102 26 */
Chris@102 27
Chris@102 28 namespace boost{
Chris@102 29
Chris@102 30 namespace serialization{
Chris@102 31
Chris@102 32 template<
Chris@102 33 class Archive,
Chris@102 34 typename T,typename Arg1,typename Arg2,typename Arg3
Chris@102 35 >
Chris@102 36 inline void serialize(
Chris@102 37 Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
Chris@102 38 const unsigned int version)
Chris@102 39 {
Chris@102 40 split_free(ar,f,version);
Chris@102 41 }
Chris@102 42
Chris@102 43 template<
Chris@102 44 class Archive,
Chris@102 45 typename T,typename Arg1,typename Arg2,typename Arg3
Chris@102 46 >
Chris@102 47 void save(
Chris@102 48 Archive& ar,const ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
Chris@102 49 const unsigned int version)
Chris@102 50 {
Chris@102 51 typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
Chris@102 52 typedef ::boost::flyweights::detail::save_helper<flyweight> helper;
Chris@102 53 typedef typename helper::size_type size_type;
Chris@102 54
Chris@102 55 helper& hlp=ar.template get_helper<helper>();
Chris@102 56
Chris@102 57 size_type n=hlp.find(f);
Chris@102 58 ar<<make_nvp("item",n);
Chris@102 59 if(n==hlp.size()){
Chris@102 60 ar<<make_nvp("key",f.get_key());
Chris@102 61 hlp.push_back(f);
Chris@102 62 }
Chris@102 63 }
Chris@102 64
Chris@102 65 template<
Chris@102 66 class Archive,
Chris@102 67 typename T,typename Arg1,typename Arg2,typename Arg3
Chris@102 68 >
Chris@102 69 void load(
Chris@102 70 Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
Chris@102 71 const unsigned int version)
Chris@102 72 {
Chris@102 73 typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
Chris@102 74 typedef typename flyweight::key_type key_type;
Chris@102 75 typedef ::boost::flyweights::detail::load_helper<flyweight> helper;
Chris@102 76 typedef typename helper::size_type size_type;
Chris@102 77
Chris@102 78 helper& hlp=ar.template get_helper<helper>();
Chris@102 79
Chris@102 80 size_type n=0;
Chris@102 81 ar>>make_nvp("item",n);
Chris@102 82 if(n>hlp.size()){
Chris@102 83 throw_exception(
Chris@102 84 archive::archive_exception(archive::archive_exception::other_exception));
Chris@102 85 }
Chris@102 86 else if(n==hlp.size()){
Chris@102 87 ::boost::flyweights::detail::archive_constructed<key_type> k(
Chris@102 88 "key",ar,version);
Chris@102 89 hlp.push_back(flyweight(k.get()));
Chris@102 90 }
Chris@102 91 f=hlp[n];
Chris@102 92 }
Chris@102 93
Chris@102 94 } /* namespace serialization */
Chris@102 95
Chris@102 96 } /* namespace boost */
Chris@102 97
Chris@102 98 #endif