Boost logo

Boost Users :

Subject: [Boost-users] [serialization] deriving from xml_iarchive
From: Kenny Riddile (kfriddile_at_[hidden])
Date: 2009-04-16 13:23:26


I have a situation where I want an additional piece of data to be owned
by the archive type we're using. Previously, I had this typedef that's
used throughout our code:

     typedef boost::archive::xml_iarchive IutputArchive;

I changed it to something like this:

     class InputArchive : public boost::archive::xml_iarchive
     {
     public:
         InputArchive( std::istream& is, Foo bar )
             : boost::archive::xml_iarchive( is )
             , m_bar( bar )

         Foo GetFoo() const
         {
             return m_bar;
         }

     private:
         Foo m_bar;
     };

The problem I'm seeing is that whenever a serializable class's
serialize() method is invoked via an InputArchive object, the template
parameter to serialize() is instantiated with
boost::archive::xml_iarchive, not InputArchive, which I need. Is it
possible to get the behavior I want through public derivation like this,
or is there a better way?


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