epoc32/include/stdapis/boost/serialization/serialization.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/serialization/serialization.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,179 @@
     1.4 +#ifndef BOOST_SERIALIZATION_SERIALIZATION_HPP
     1.5 +#define BOOST_SERIALIZATION_SERIALIZATION_HPP
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
     1.9 +# pragma once
    1.10 +#endif
    1.11 +
    1.12 +#if defined(_MSC_VER) && (_MSC_VER >= 1310)
    1.13 +#  pragma warning (disable : 4675) // suppress ADL warning
    1.14 +#endif
    1.15 +
    1.16 +#include <cstddef> // size_t
    1.17 +#include <boost/config.hpp>
    1.18 +#if defined(BOOST_NO_STDC_NAMESPACE)
    1.19 +namespace std{ 
    1.20 +    using ::size_t; 
    1.21 +} // namespace std
    1.22 +#endif
    1.23 +
    1.24 +#include <boost/strong_typedef.hpp>
    1.25 +#include <boost/pfto.hpp>
    1.26 +#include <boost/throw_exception.hpp>
    1.27 +#include <boost/serialization/nvp.hpp>
    1.28 +
    1.29 +// incremented for each "release"
    1.30 +#define BOOST_SERIALIZATION_LIBRARY_VERSION 19
    1.31 +
    1.32 +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
    1.33 +// serialization.hpp: interface for serialization system.
    1.34 +
    1.35 +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
    1.36 +// Use, modification and distribution is subject to the Boost Software
    1.37 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    1.38 +// http://www.boost.org/LICENSE_1_0.txt)
    1.39 +
    1.40 +//  See http://www.boost.org for updates, documentation, and revision history.
    1.41 +
    1.42 +//////////////////////////////////////////////////////////////////////
    1.43 +// public interface to serialization. 
    1.44 +
    1.45 +/////////////////////////////////////////////////////////////////////////////
    1.46 +// layer 0 - intrusive verison
    1.47 +// declared and implemented for each user defined class to be serialized
    1.48 +//
    1.49 +//  template<Archive>
    1.50 +//  serialize(Archive &ar, const unsigned int file_version){
    1.51 +//      ar & base_object<base>(*this) & member1 & member2 ... ;
    1.52 +//  }
    1.53 +
    1.54 +/////////////////////////////////////////////////////////////////////////////
    1.55 +// layer 1 - layer that routes member access through the access class.
    1.56 +// this is what permits us to grant access to private class member functions
    1.57 +// by specifying friend class boost::serialization::access
    1.58 +
    1.59 +#include <boost/serialization/access.hpp>
    1.60 +
    1.61 +/////////////////////////////////////////////////////////////////////////////
    1.62 +// layer 2 - default implementation of non-intrusive serialization.
    1.63 +//
    1.64 +// note the usage of function overloading to compensate that C++ does not
    1.65 +// currently support Partial Template Specialization for function templates 
    1.66 +// We have declared the version number as "const unsigned long".  
    1.67 +// Overriding templates for specific data types should declare the version
    1.68 +// number as "const unsigned int". Template matching will first be applied
    1.69 +// to functions with the same version types - that is the overloads.  
    1.70 +// If there is no declared function prototype that matches, the second argument
    1.71 +// will be converted to "const unsigned long" and a match will be made with 
    1.72 +// one of the default template functions below.
    1.73 +
    1.74 +namespace boost {
    1.75 +namespace serialization {
    1.76 +
    1.77 +BOOST_STRONG_TYPEDEF(unsigned int, version_type)
    1.78 +
    1.79 +// default implemenation - call the member function "serialize"
    1.80 +template<class Archive, class T>
    1.81 +inline void serialize(
    1.82 +    Archive & ar, T & t, const BOOST_PFTO unsigned int file_version
    1.83 +){
    1.84 +    access::serialize(ar, t, static_cast<unsigned int>(file_version));
    1.85 +}
    1.86 +
    1.87 +// save data required for construction
    1.88 +template<class Archive, class T>
    1.89 +inline void save_construct_data(
    1.90 +    Archive & /*ar*/, 
    1.91 +    const T * /*t*/, 
    1.92 +    const BOOST_PFTO unsigned int /*file_version */
    1.93 +){
    1.94 +    // default is to save no data because default constructor
    1.95 +    // requires no arguments.
    1.96 +}
    1.97 +
    1.98 +// load data required for construction and invoke constructor in place
    1.99 +template<class Archive, class T>
   1.100 +inline void load_construct_data(
   1.101 +    Archive & ar, 
   1.102 +    T * t, 
   1.103 +    const BOOST_PFTO unsigned int /*file_version*/
   1.104 +){
   1.105 +    // default just uses the default constructor.  going
   1.106 +    // through access permits usage of otherwise private default
   1.107 +    // constructor
   1.108 +    access::construct(ar, t);
   1.109 +}
   1.110 +
   1.111 +/////////////////////////////////////////////////////////////////////////////
   1.112 +// layer 3 - move call into serialization namespace so that ADL will function
   1.113 +// in the manner we desire.
   1.114 +//
   1.115 +// on compilers which don't implement ADL. only the current namespace
   1.116 +// i.e. boost::serialization will be searched.
   1.117 +// 
   1.118 +// on compilers which DO implement ADL
   1.119 +// serialize overrides can be in any of the following
   1.120 +// 
   1.121 +// 1) same namepace as Archive
   1.122 +// 2) same namespace as T
   1.123 +// 3) boost::serialization
   1.124 +//
   1.125 +// Due to Martin Ecker
   1.126 +
   1.127 +template<class Archive, class T>
   1.128 +inline void serialize_adl(
   1.129 +    Archive & ar, 
   1.130 +    T & t, 
   1.131 +    const unsigned int file_version
   1.132 +){
   1.133 +    // note usage of function overloading to delay final resolution
   1.134 +    // until the point of instantiation.  This works around the two-phase
   1.135 +    // lookup "feature" which inhibits redefintion of a default function
   1.136 +    // template implementation. Due to Robert Ramey
   1.137 +    //
   1.138 +    // Note that this trick generates problems for compiles which don't support
   1.139 +    // PFTO, suppress it here.  As far as we know, there are no compilers
   1.140 +    // which fail to support PFTO while supporting two-phase lookup.
   1.141 +    #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
   1.142 +        const version_type v(file_version);
   1.143 +        serialize(ar, t, v);
   1.144 +    #else
   1.145 +        serialize(ar, t, file_version);
   1.146 +    #endif
   1.147 +}
   1.148 +
   1.149 +template<class Archive, class T>
   1.150 +inline void save_construct_data_adl(
   1.151 +    Archive & ar, 
   1.152 +    const T * t, 
   1.153 +    const unsigned int file_version
   1.154 +){
   1.155 +    // see above
   1.156 +    #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
   1.157 +        const version_type v(file_version);
   1.158 +        save_construct_data(ar, t, v);
   1.159 +    #else
   1.160 +        save_construct_data(ar, t, file_version);
   1.161 +    #endif
   1.162 +}
   1.163 +
   1.164 +template<class Archive, class T>
   1.165 +inline void load_construct_data_adl(
   1.166 +    Archive & ar, 
   1.167 +    T * t, 
   1.168 +    const unsigned int file_version
   1.169 +){
   1.170 +    // see above comment
   1.171 +    #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
   1.172 +        const version_type v(file_version);
   1.173 +        load_construct_data(ar, t, v);
   1.174 +    #else
   1.175 +        load_construct_data(ar, t, file_version);
   1.176 +    #endif
   1.177 +}
   1.178 +
   1.179 +} // namespace serialization
   1.180 +} // namespace boost
   1.181 +
   1.182 +#endif //BOOST_SERIALIZATION_SERIALIZATION_HPP