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

// 指针
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<param_type*,storage_class,_storage_type>
{
    inline iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,param_type*& param)
    {
        unsigned int addr;
        From_Archive_Helper<_storage_type,storage_class,unsigned int> f_a_h(*(helper._storage),addr,*helper._storage_pos);
        param = traits::pointer_integer_traits<param_type*>(addr);
    }
};

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

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

// std::list
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<std::list<param_type>,storage_class,_storage_type>
{
    inline iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,std::list<param_type>& param)
    {
        unsigned int size = 0;
        iarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,size);
        for (unsigned int i=0; i<size; ++i)
        {
            param_type p;
            iarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,p);
            param.push_back(p);
        }
    }
};

// std::vector
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<std::vector<param_type>,storage_class,_storage_type>
{
    inline iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,std::vector<param_type>& param)
    {
        unsigned int size = 0;
        iarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,size);
        for (unsigned int i=0; i<size; ++i)
        {
            param_type p;
            iarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,p);
            param.push_back(p);
        }
    }
};

// std::stack
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct iarchive_impl_helper<std::stack<param_type>,storage_class,_storage_type>
{
    inline iarchive_impl_helper(iarchive_param_deliverer<storage_class,_storage_type>& helper,std::stack<param_type>& param)
    {
        std::stack<param_type> new_param;
        unsigned int size = 0;
        iarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,size);
        for (unsigned int i=0; i<size; ++i)
        {
            param_type p;
            iarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,p);
            new_param.push(p);
        }

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

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