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

// std::string
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::string,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::string& param)
    {
        To_Archive_Helper<_storage_type,storage_class,std::string> t_a_h(*(helper._storage),param);
    }
};

/// std::wstring
template<typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::wstring,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::wstring& param)
    {
        To_Archive_Helper<_storage_type,storage_class,std::wstring> t_a_h(*(helper._storage),param);
    }
};

/// std::list
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::list<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::list<param_type>& param)
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)param.size());
        for (typename std::list<param_type>::const_iterator iter=param.begin(); iter!=param.end(); ++iter)
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,(param_type)(*iter));
    }
};

/// std::vector
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::vector<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::vector<param_type>& param)
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)param.size());
        for (typename std::vector<param_type>::const_iterator iter=param.begin(); iter!=param.end(); ++iter)
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,(param_type)(*iter));
    }
};

/// std::stack
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::stack<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::stack<param_type>& param)
    {
        std::stack<param_type> new_param = param;
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)new_param.size());
        while(!new_param.empty())
        {
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,(param_type)new_param.top());
            new_param.pop();
        }
    }
};

/// std::queue
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::queue<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::queue<param_type>& param)
    {
        std::queue<param_type> new_param = param;
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)new_param.size());
        while(!new_param.empty())
        {
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,(param_type)new_param.front());
            new_param.pop();
        }
    }
};

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

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