Boost logo

Boost Users :

From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2005-12-15 21:08:52


I am using Boost 1.33.0 with MinGW 3.4.2. I plan to use the Boost serialization
library in a project I am working on. Following the tutorial (but allowing for
XML archives rather than text) I have successfully included code like the
following in my classes:

#include <fstream>
#include "boost/archive/xml_oarchive.hpp"
#include "boost/archive/xml_iarchive.hpp"

class ClassWhatever {
private:
   friend class boost::serialization::access;
    template<class Archive>
        void serialize(Archive& ar, const unsigned int version) {
                ar & mResults;
                ar & mInputs;
                ar & mDisplayObject;
    }//serialize()
    . . .
};

This code compiles without error in all classes.

Now, I'm writing unit tests for the classes and I want to trigger the save
and later reload of these classes. Following the same serialization tutorial,
I tried this:

    . . .
    {
         ofstream outStream(archiveFile);
        boost::archive::xml_oarchive outArchive(outStream);
         outArchive << testObj_out;
    } // archive and stream closed when destructors are called
    . . .

and similar code for the later load from the archive. When I compile this,
I get massive errors, a few of which are shown below. (I've manually
wrapped the long lines in an attempt to make it more readable--but I
may have just made it worse.)

I'm sort of guessing that there is a header or two missing. Any suggestions?

Also, there are "polymorphic_..." versions of the archive files available, but
I don't remember seeing them mentioned in the documentation. I have
polymorphic classes. Should I be using the polymorphic versions of the
headers?

Merrill
========================================

E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:
     In member function `void boost::archive::basic_xml_oarchive<Archive>::
     save_override(T&, int) [with T = boost::shared_ptr<WkFlo::Successor>,
     Archive = boost::archive::xml_oarchive]':
E:/Dev-Cpp/Workflow/boost/include/boost/archive/detail/interface_oarchive.hpp:85:
    instantiated from `Archive& boost::archive::detail::interface_oarchive<Archive>::
    operator<<(T&) [with T = WkFlo::Successor_ptr, Archive =
    boost::archive::xml_oarchive]'
E:/Dev-Cpp/Workflow/test/src/Successor_Test.cc:111:
    instantiated from here
E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:86:
    error: incomplete type `boost::STATIC_ASSERTION_FAILURE< false>'
    used in nested name specifier
E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:86:
    error: size of array has non-integral type `<type error>'
E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_iarchive.hpp:
    In member function `void boost::archive::basic_xml_iarchive<Archive>::
    load_override(T&, int) [with T = boost::shared_ptr<WkFlo::Successor>,
    Archive = boost::archive::xml_iarchive]':
E:/Dev-Cpp/Workflow/boost/include/boost/archive/xml_iarchive.hpp:74:
    instantiated from `void boost::archive::xml_iarchive_impl<Archive>::
    load_override(T&, int) [with T = boost::shared_ptr<WkFlo::Successor>,
   Archive = boost::archive::xml_iarchive]'
E:/Dev-Cpp/Workflow/boost/include/boost/archive/detail/interface_iarchive.hpp:84:
    instantiated from `Archive& boost::archive::detail::interface_iarchive<Archive>::
    operator>>(T&) [with T = WkFlo::Successor_ptr, Archive =
    boost::archive::xml_iarchive]'
E:/Dev-Cpp/Workflow/test/src/Successor_Test.cc:121:
    instantiated from here
. . . and so on


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