Boost logo

Boost Users :

From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2005-12-23 20:05:04


Robert,

I just now got home to try adding the two NVP wrappers you suggested.
The old problems went away, but there's a new set:

Merrill

Succ.h===========================================
#include "boost/serialization/nvp.hpp"
#include "boost/test/test_tools.hpp"

namespace MyNS {
class Succ {
        friend class Succ_Test;

private:
        size_t mInputIndex;
        bool mIsInbound;

    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive& ar, const unsigned int version) {
        ar & BOOST_SERIALIZATION_NVP(mInputIndex);
        ar & BOOST_SERIALIZATION_NVP(mIsInbound);
    }//serialize()

public:
        Succ() {} // needed by serialization
        Succ(size_t inputIndex, bool isInbound);
        virtual ~Succ();
        size_t inputIndex() const;
        bool isInbound() const;
};//Succ
}//MyNS

Succ_Test.cc===================================
#include <fstream>
#include "Succ.h"

#include "boost/archive/xml_iarchive.hpp"
#include "boost/archive/xml_oarchive.hpp"
#include "boost/test/test_tools.hpp"

using namespace std;

namespace MyNS {

class Succ_Test {
public:
    void run();
};//Succ_Test
//=============================================================================

void Succ_Test::run() {
        const char* archiveFile = "temp/Succ_archive.xml";
        size_t inputIndex = 65;
        bool isInbound = true;

        Succ* testObj_out = new Succ(inputIndex, isInbound);
    {
                // save data to archive
                ofstream outStream(archiveFile);
                boost::archive::xml_oarchive outArchive(outStream);

                // write class instance to archive
        outArchive << BOOST_SERIALIZATION_NVP(testObj_out);
        } // archive and stream closed when destructors are called

        Succ* testObj_in;// = new Succ();
        {
                // create and open an archive for input
        ifstream inStream(archiveFile);
        boost::archive::xml_iarchive inArchive(inStream);
 
                // read class state from archive
        inArchive >> BOOST_SERIALIZATION_NVP(testObj_in);
        } // archive and stream closed when destructors are called
        return;
}//run()
}//MyNS

compile stderr========================================
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:
    In static member function `static void boost::archive::detail::save_pointer_type<Archive, TPtr>::save(Archive&, const T&, const boost::archive::detail::basic_pointer_oserializer*) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]':
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:467:
    instantiated from `static void boost::archive::detail::save_pointer_type<Archive, TPtr>::invoke(Archive&, TPtr) [with Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:536:
    instantiated from `void boost::archive::save(Archive&, const T&) [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_oarchive.hpp:99:
    instantiated from `void boost::archive::basic_xml_oarchive<Archive>::save_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_oarchive.hpp:78:
    instantiated from `Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_oarchive]'
Foo/test/src/Succ_Test.cc:48:
    instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:438:
    error: invalid use of undefined type `struct boost::serialization::extended_type_info_null<MyNS::Succ>'
Foo/boost-1_33_1/include/boost/serialization/type_info_implementation.hpp:26:
    error: declaration of `struct boost::serialization::extended_type_info_null<MyNS::Succ>'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:439:
    error: invalid use of undefined type `struct boost::serialization::extended_type_info_null<MyNS::Succ>'
Foo/boost-1_33_1/include/boost/serialization/type_info_implementation.hpp:26:
    error: declaration of `struct boost::serialization::extended_type_info_null<MyNS::Succ>'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:439:
    error: `save' is not a member of `<declaration error>'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:
    In static member function `static T* boost::archive::detail::load_pointer_type<Archive, Tptr>::pointer_tweak(const boost::serialization::extended_type_info&, void*, T&) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]':
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:493:
    instantiated from `static void boost::archive::detail::load_pointer_type<Archive, Tptr>::invoke(Archive&, Tptr&) [with Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:572:
    instantiated from `void boost::archive::load(Archive&, T&) [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_iarchive.hpp:80:
    instantiated from `void boost::archive::basic_xml_iarchive<Archive>::load_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/xml_iarchive.hpp:74:
    instantiated from `void boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_iarchive.hpp:76:
    instantiated from `Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/test/src/Succ_Test.cc:58:
    instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:475:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:
    In constructor `boost::archive::detail::pointer_oserializer<T, Archive>::pointer_oserializer() [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]':
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:198:
    instantiated from `const boost::archive::detail::pointer_oserializer<MyNS::Succ, boost::archive::xml_oarchive> boost::archive::detail::pointer_oserializer<MyNS::Succ, boost::archive::xml_oarchive>::instance'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:190:
    instantiated from `static const boost::archive::detail::pointer_oserializer<T, Archive>& boost::archive::detail::pointer_oserializer<T, Archive>::instantiate() [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:515:
    instantiated from `const boost::archive::detail::basic_pointer_oserializer& boost::archive::detail::instantiate_pointer_oserializer(Archive*, T*) [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_oarchive.hpp:58:
    instantiated from `const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::interface_oarchive<Archive>::register_type(const T*) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:344:
    instantiated from `static const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::save_pointer_type<Archive, TPtr>::non_abstract<T>::register_type(Archive&) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:360:
    instantiated from `static const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::save_pointer_type<Archive, TPtr>::register_type(Archive&, T&) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:460:
    instantiated from `static void boost::archive::detail::save_pointer_type<Archive, TPtr>::invoke(Archive&, TPtr) [with Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:536:
    instantiated from `void boost::archive::save(Archive&, const T&) [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_oarchive.hpp:99:
    instantiated from `void boost::archive::basic_xml_oarchive<Archive>::save_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_oarchive.hpp:78:
    instantiated from `Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_oarchive]'
Foo/test/src/Succ_Test.cc:48:
    instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:233:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:233:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:
    In constructor `boost::archive::detail::pointer_iserializer<T, Archive>::pointer_iserializer() [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]':
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:211:
    instantiated from `const boost::archive::detail::pointer_iserializer<MyNS::Succ, boost::archive::xml_iarchive> boost::archive::detail::pointer_iserializer<MyNS::Succ, boost::archive::xml_iarchive>::instance'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:203:
    instantiated from `static const boost::archive::detail::pointer_iserializer<T, Archive>& boost::archive::detail::pointer_iserializer<T, Archive>::instantiate() [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:546:
    instantiated from `const boost::archive::detail::basic_pointer_iserializer& boost::archive::detail::instantiate_pointer_iserializer(Archive*, T*) [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_iarchive.hpp:57:
    instantiated from `const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::interface_iarchive<Archive>::register_type(T*) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:449: instantiated from `static const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::load_pointer_type<Archive, Tptr>::non_abstract<T>::register_type(Archive&) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:465: instantiated from `static const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::load_pointer_type<Archive, Tptr>::register_type(Archive&, T&) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:485: instantiated from `static void boost::archive::detail::load_pointer_type<Archive, Tptr>::invoke(Archive&, Tptr&) [with Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:572: instantiated from `void boost::archive::load(Archive&, T&) [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_iarchive.hpp:80: instantiated from `void boost::archive::basic_xml_iarchive<Archive>::load_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/xml_iarchive.hpp:74: instantiated from `void boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_iarchive.hpp:76: instantiated from `Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/test/src/Succ_Test.cc:58: instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:339:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:339:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:
    In constructor `boost::archive::detail::oserializer<Archive, T>::oserializer() [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ]':
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:135:
    instantiated from `static boost::archive::detail::oserializer<Archive, T>& boost::archive::detail::oserializer<Archive, T>::instantiate() [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:235:
    instantiated from `boost::archive::detail::pointer_oserializer<T, Archive>::pointer_oserializer() [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:198:
    instantiated from `const boost::archive::detail::pointer_oserializer<MyNS::Succ, boost::archive::xml_oarchive> boost::archive::detail::pointer_oserializer<MyNS::Succ, boost::archive::xml_oarchive>::instance'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:190:
    instantiated from `static const boost::archive::detail::pointer_oserializer<T, Archive>& boost::archive::detail::pointer_oserializer<T, Archive>::instantiate() [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:515:
    instantiated from `const boost::archive::detail::basic_pointer_oserializer& boost::archive::detail::instantiate_pointer_oserializer(Archive*, T*) [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_oarchive.hpp:58:
    instantiated from `const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::interface_oarchive<Archive>::register_type(const T*) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:344:
    instantiated from `static const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::save_pointer_type<Archive, TPtr>::non_abstract<T>::register_type(Archive&) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:360:
    instantiated from `static const boost::archive::detail::basic_pointer_oserializer* boost::archive::detail::save_pointer_type<Archive, TPtr>::register_type(Archive&, T&) [with T = MyNS::Succ, Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:460:
    instantiated from `static void boost::archive::detail::save_pointer_type<Archive, TPtr>::invoke(Archive&, TPtr) [with Archive = boost::archive::xml_oarchive, TPtr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:536:
    instantiated from `void boost::archive::save(Archive&, const T&) [with Archive = boost::archive::xml_oarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_oarchive.hpp:99:
    instantiated from `void boost::archive::basic_xml_oarchive<Archive>::save_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_oarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_oarchive.hpp:78:
    instantiated from `Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_oarchive]'
Foo/test/src/Succ_Test.cc:48:
    instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/oserializer.hpp:108:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:
    In constructor `boost::archive::detail::iserializer<Archive, T>::iserializer() [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ]':
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:146:
    instantiated from `static boost::archive::detail::iserializer<Archive, T>& boost::archive::detail::iserializer<Archive, T>::instantiate() [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:340:
    instantiated from `boost::archive::detail::pointer_iserializer<T, Archive>::pointer_iserializer() [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:211:
    instantiated from `const boost::archive::detail::pointer_iserializer<MyNS::Succ, boost::archive::xml_iarchive> boost::archive::detail::pointer_iserializer<MyNS::Succ, boost::archive::xml_iarchive>::instance'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:203:
    instantiated from `static const boost::archive::detail::pointer_iserializer<T, Archive>& boost::archive::detail::pointer_iserializer<T, Archive>::instantiate() [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:546:
    instantiated from `const boost::archive::detail::basic_pointer_iserializer& boost::archive::detail::instantiate_pointer_iserializer(Archive*, T*) [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_iarchive.hpp:57:
    instantiated from `const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::interface_iarchive<Archive>::register_type(T*) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:449:
    instantiated from `static const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::load_pointer_type<Archive, Tptr>::non_abstract<T>::register_type(Archive&) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:465:
    instantiated from `static const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::load_pointer_type<Archive, Tptr>::register_type(Archive&, T&) [with T = MyNS::Succ, Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:485:
    instantiated from `static void boost::archive::detail::load_pointer_type<Archive, Tptr>::invoke(Archive&, Tptr&) [with Archive = boost::archive::xml_iarchive, Tptr = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:572:
    instantiated from `void boost::archive::load(Archive&, T&) [with Archive = boost::archive::xml_iarchive, T = MyNS::Succ*]'
Foo/boost-1_33_1/include/boost/archive/basic_xml_iarchive.hpp:80:
    instantiated from `void boost::archive::basic_xml_iarchive<Archive>::load_override(const boost::serialization::nvp<T>&, int) [with T = MyNS::Succ*, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/xml_iarchive.hpp:74:
    instantiated from `void boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/boost-1_33_1/include/boost/archive/detail/interface_iarchive.hpp:76:
    instantiated from `Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const boost::serialization::nvp<MyNS::Succ*>, Archive = boost::archive::xml_iarchive]'
Foo/test/src/Succ_Test.cc:58:
    instantiated from here
Foo/boost-1_33_1/include/boost/archive/detail/iserializer.hpp:115:
    error: incomplete type `boost::serialization::extended_type_info_null<MyNS::Succ>' used in nested name specifier
make: *** [test/obj/Succ_Test.o] Error 1
//========================================================


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net