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

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

/// std::Set
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::set<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::set<param_type>& param)
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)param.size());
        for (typename std::set<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::multiset
template<typename param_type,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::multiset<param_type>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::multiset<param_type>& param)
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)param.size());
        for (typename std::set<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::multimap
template<typename param_type,typename param_type2,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<std::multimap<param_type,param_type2>,storage_class,_storage_type>
{
    inline oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const std::multimap<param_type,param_type2>& param)
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)param.size());
        for (typename std::multimap<param_type,param_type2>::const_iterator iter=param.begin();iter!=param.end(); ++iter)
        {
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,(param_type)(iter->first));
            oarchive_impl_helper<param_type2,storage_class,_storage_type> impl2(helper,(param_type2)(iter->second));
        }
    }
};

///////////////////// stl end //////////////////

/// array
template<typename param_type,unsigned int NUM,typename storage_class,storage_type::VEHICLE_TYPE _storage_type>
struct oarchive_impl_helper<param_type(&)[NUM],storage_class,_storage_type>
{
    oarchive_impl_helper(oarchive_param_deliverer<storage_class,_storage_type>& helper,const param_type (&param)[NUM])
    {
        oarchive_impl_helper<unsigned int,storage_class,_storage_type> impl(helper,(unsigned int)NUM);
        for (unsigned int i=0; i<NUM; ++i)
            oarchive_impl_helper<param_type,storage_class,_storage_type> impl(helper,param[i]);
    }
};

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

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

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