Beispiel #1
0
inline void save_collection(
    Archive & ar,
    const Container &s,
    collection_size_type count)
{
    ar << BOOST_SERIALIZATION_NVP(count);
    // record number of elements
    const item_version_type item_version(
        version<typename Container::value_type>::value
    );
    #if 0
        pdalboost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(pdalboost::archive::library_version_type(3) < library_version){
            ar << BOOST_SERIALIZATION_NVP(item_version);
        }
    #else
        ar << BOOST_SERIALIZATION_NVP(item_version);
    #endif

    typename Container::const_iterator it = s.begin();
    while(count-- > 0){
        // note borland emits a no-op without the explicit namespace
        pdalboost::serialization::save_construct_data_adl(
            ar, 
            &(*it), 
            item_version
        );
        ar << pdalboost::serialization::make_nvp("item", *it++);
    }
}
inline void save_hash_collection(Archive & ar, const Container &s)
{
    collection_size_type count(s.size());
    const collection_size_type bucket_count(s.bucket_count());
    const item_version_type item_version(
        version<BOOST_DEDUCED_TYPENAME Container::value_type>::value
    );

#if 0
    /* should only be necessary to create archives of previous versions
     * which is not currently supported.  So for now comment this out
     */
    lslboost::archive::library_version_type library_version(
        ar.get_library_version()
    );
    // retrieve number of elements
    if(lslboost::archive::library_version_type(6) != library_version) {
        ar << BOOST_SERIALIZATION_NVP(count);
        ar << BOOST_SERIALIZATION_NVP(bucket_count);
    }
    else {
        // note: fixup for error in version 6.  collection size was
        // changed to size_t BUT for hashed collections it was implemented
        // as an unsigned int.  This should be a problem only on win64 machines
        // but I'll leave it for everyone just in case.
        const unsigned int c = count;
        const unsigned int bc = bucket_count;
        ar << BOOST_SERIALIZATION_NVP(c);
        ar << BOOST_SERIALIZATION_NVP(bc);
    }
    if(lslboost::archive::library_version_type(3) < library_version) {
        // record number of elements
        // make sure the target type is registered so we can retrieve
        // the version when we load
        ar << BOOST_SERIALIZATION_NVP(item_version);
    }
#else
    ar << BOOST_SERIALIZATION_NVP(count);
    ar << BOOST_SERIALIZATION_NVP(bucket_count);
    ar << BOOST_SERIALIZATION_NVP(item_version);
#endif

    BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
    while(count-- > 0) {
        // note borland emits a no-op without the explicit namespace
        lslboost::serialization::save_construct_data_adl(
            ar,
            &(*it),
            lslboost::serialization::version<
            BOOST_DEDUCED_TYPENAME Container::value_type
            >::value
        );
        ar << lslboost::serialization::make_nvp("item", *it++);
    }
}
inline void load_hash_collection(Archive & ar, Container &s)
{
    collection_size_type count;
    collection_size_type bucket_count;
    boost::serialization::item_version_type item_version(0);
    boost::archive::library_version_type library_version(
        ar.get_library_version()
    );
    // retrieve number of elements
    if(boost::archive::library_version_type(6) != library_version){
        ar >> BOOST_SERIALIZATION_NVP(count);
        ar >> BOOST_SERIALIZATION_NVP(bucket_count);
    }
inline void save_unordered_collection(Archive & ar, const Container &s)
{
    collection_size_type count(s.size());
    const collection_size_type bucket_count(s.bucket_count());
    const item_version_type item_version(
        version<BOOST_DEDUCED_TYPENAME Container::value_type>::value
    );

    #if 0
    /* should only be necessary to create archives of previous versions
     * which is not currently supported.  So for now comment this out
     */
    boost::archive::library_version_type library_version(
        ar.get_library_version()
    );
    // retrieve number of elements
    ar << BOOST_SERIALIZATION_NVP(count);
    ar << BOOST_SERIALIZATION_NVP(bucket_count);
    if(boost::archive::library_version_type(3) < library_version){
        // record number of elements
        // make sure the target type is registered so we can retrieve
        // the version when we load
        ar << BOOST_SERIALIZATION_NVP(item_version);
    }
    #else
        ar << BOOST_SERIALIZATION_NVP(count);
        ar << BOOST_SERIALIZATION_NVP(bucket_count);
        ar << BOOST_SERIALIZATION_NVP(item_version);
    #endif

    BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
    while(count-- > 0){
        // note borland emits a no-op without the explicit namespace
        boost::serialization::save_construct_data_adl(
            ar, 
            &(*it), 
            boost::serialization::version<
                BOOST_DEDUCED_TYPENAME Container::value_type
            >::value
        );
        ar << boost::serialization::make_nvp("item", *it++);
    }
}
Beispiel #5
0
void load(
    Archive & ar,
    boost::optional< T > & t,
    const unsigned int version
){
    bool tflag;
    ar >> boost::serialization::make_nvp("initialized", tflag);
    if(! tflag){
        t.reset();
        return;
    }

    if(0 == version){
        boost::serialization::item_version_type item_version(0);
        boost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(boost::archive::library_version_type(3) < library_version){
            ar >> BOOST_SERIALIZATION_NVP(item_version);
        }
void load(
    Archive & ar, 
    lslboost::optional< T > & t, 
    const unsigned int /*version*/
){
    bool tflag;
    ar >> lslboost::serialization::make_nvp("initialized", tflag);
    if (tflag){
        lslboost::serialization::item_version_type item_version(0);
        lslboost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(lslboost::archive::library_version_type(3) < library_version){
            // item_version is handled as an attribute so it doesnt need an NVP
           ar >> BOOST_SERIALIZATION_NVP(item_version);
        }
        detail::stack_construct<Archive, T> aux(ar, item_version);
        ar >> lslboost::serialization::make_nvp("value", aux.reference());
        t.reset(aux.reference());
    }