Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-02-26 15:29:03


Sorry, I haven't looked into it.

Looking at ...basic_binary_archive I do see that the meta data - object id, etc
are converted to integer types so it looks like this issue was considered. So its not a super obvious issue. I do believe that by making a small test - serializing each of the meta data tag types, you might reveal which one - or more - are hanging things up. Try making a small test:

boost::archive::class_id cid = 100;
ar << cid;
ar << 324;
...

boost::archive::class_id cid
ar >> cid;
assert(100 == cide);
ar >> i;
assert(i == 324);
...

That would be helpful.

Robert Ramey

  "Dan Leibovich" <dan_at_[hidden]> wrote in message news:80726DBE398EBB4A8B77AD210C509EAA0291B077_at_MAILEU.global.cadence.com...
  Hi Robert,

  Were you able to find some clue?

  I don't think it is related to the problem but there are some compilation warnings, do you have suggestion how to avoid it?

../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member
   function `void boost::archive::basic_binary_iarchive<Archive>::init() [with
   Archive = portable_binary_iarchive]':
portable_binary_iarchive.hpp:116: instantiated from here
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing
   `boost::archive::version_type::operator unsigned int&()' over `
   boost::archive::version_type::operator const unsigned int&() const'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
    for conversion from `boost::archive::version_type' to `unsigned int'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
    because conversion sequence for the argument is better
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member
   function `void boost::archive::basic_binary_iarchive<Archive>::init() [with
   Archive = boost::archive::binary_iarchive]':
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:51: instantiated from `void boost::archive::binary_iarchive_impl<Archive>::init() [with Archive = boost::archive::binary_iarchive]'
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:66: instantiated from `boost::archive::binary_iarchive_impl<Archive>::binary_iarchive_impl(std::istream&, unsigned int) [with Archive = boost::archive::binary_iarchive]'
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:80: instantiated from here
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing
   `boost::archive::version_type::operator unsigned int&()' over `
   boost::archive::version_type::operator const unsigned int&() const'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
    for conversion from `boost::archive::version_type' to `unsigned int'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
    because conversion sequence for the argument is better
  Thank you
   Dan

----------------------------------------------------------------------------
    From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Ramey
    Sent: ã 21 ôáøåàø 2007 21:54
    To: boost-users_at_[hidden]
    Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive

    We'll look into it. If you get any more information, feel free to share it.

    Robert Ramey

      "Dan Leibovich" <dan_at_[hidden]> wrote in message news:80726DBE398EBB4A8B77AD210C509EAA0291A579_at_MAILEU.global.cadence.com...
      Hi,
      I am trying to use the portable binary archive example.
      I need to serialize only integers and strings.

      I tried it on linux and solaris5.8. The result binary stream is not the same and deserialization fails.

      I used hex viewer and notice that the files are very similar except for some few differences which results from endienness issues. Can it be that the metadata is written differently on each platform.

      This is happens when I serialize derived class through a pointer to base class. (I used BOOS_CLASS_EXPORT)

      Below you will find a test case. It produce differ output on linux and solaris.

      Am I missing something?

      Thanks in advance
       Dan Leibovich

      #include <fstream>
      #include "portable_binary_oarchive.hpp"

      #include <boost/serialization/base_object.hpp>
      #include <boost/serialization/export.hpp>

      class Base {
      private:
          friend class boost::serialization::access;
          template<class Archive>
          void serialize(Archive & ar, const unsigned int version)
          {
              ar & x;
          }

      protected:
          int x;

      public:
        Base() {} ;
        Base(int x_) : x(x_) {} ;
        virtual void foo() {} ;
      };

      class Derived1 : public Base {
      private:
        friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
        {
          ar & boost::serialization::base_object<Base>(*this);
          ar & y;
        }
      protected:
        int y;

      public:
        Derived1() {} ;
        Derived1(int x_, int y_) : Base(x_), y(y_) {} ;
        virtual void foo() {x++;}
      };

      class Derived2 : public Base {
      private:
        friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
        {
          ar & boost::serialization::base_object<Base>(*this);
          ar & z;
        }
      protected:
        bool z;

      public:
        Derived2() {} ;
        Derived2(int x_) : Base(x_), z(true) {} ;
        virtual void foo() {x--;}
      };

      class Container {
        Base* b1 ;
        Base* b2 ;
        friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
        {
          ar & b1;
          ar & b2 ;
        }
      public:
        Container() {} ;
        Container(int x, int y) {
          b1 = new Derived1(x,y) ;
          b2 = new Derived2(x) ;
        }
      };

      BOOST_CLASS_EXPORT(Derived1) ;
      BOOST_CLASS_EXPORT(Derived2) ;

      int main() {
          std::ofstream ofs("filename");
          const Container c(1,2) ;
          portable_binary_oarchive oa(ofs);
          oa << c;
      }
        

--------------------------------------------------------------------------

      _______________________________________________
      Boost-users mailing list
      Boost-users_at_[hidden]
      http://lists.boost.org/mailman/listinfo.cgi/boost-users

------------------------------------------------------------------------------

  _______________________________________________
  Boost-users mailing list
  Boost-users_at_[hidden]
  http://lists.boost.org/mailman/listinfo.cgi/boost-users



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