C++序列化库的实现(9)

// long
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<long,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,long& param)
    {
        From_Archive_Helper<_storage_type,storage_class,long> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// unsigned long
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<unsigned long,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,unsigned long& param)
    {
        From_Archive_Helper<_storage_type,storage_class,unsigned long> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// _int64_
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<_int64_,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,_int64_& param)
    {
        From_Archive_Helper<_storage_type,storage_class,_int64_> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// _uint64_
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<_uint64_,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,_uint64_& param)
    {
        From_Archive_Helper<_storage_type,storage_class,_uint64_> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// short
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<short,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,short& param)
    {
        From_Archive_Helper<_storage_type,storage_class,short> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// unsigned short
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<unsigned short,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,unsigned short& param)
    {
        From_Archive_Helper<_storage_type,storage_class,unsigned short> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};

// bool
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<bool,storage_class,_storage_type>
{
    iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,bool& param)
    {
        From_Archive_Helper<_storage_type,storage_class,bool> f_a_h(*helper._storage,param,*helper._storage_pos);
    }
};


NAMESPACE_SERIALIZATION_END
#endif

// oarchive_impl_helper.hpp

#ifndef OARCHIVE_IMPL_HELPER_INCLUDE
#define OARCHIVE_IMPL_HELPER_INCLUDE

#include "archive_config.hpp"
#include "to_archive.hpp"
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include "traits/traits.hpp"


NAMESPACE_SERIALIZATION_BEGIN

// 自定义
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const param_type& param)
    {
        param_type& p = const_cast<param_type&>(param);
        unsigned int version = SERIALIZATION_VERSION;
        p.serialize(*helper.m_boi,version);//archive ,out=false ,version
    }
};

// 指针
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<param_type*,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const param_type* param)
    {
        // 序列化指针指向的地址
        unsigned int addr = traits::pointer_integer_traits<unsigned int>(param);
        To_Archive_Helper<_storage_type,storage_class,unsigned int> t_a_h(*(helper._storage),addr);
    }
};

/////////for stl

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4027141282656c44471a7b6eeb1dc451.html