We'll look into it. If you get any more information, feel free to share it.
Robert Ramey
"Dan Leibovich" wrote in message news:80726DBE398EBB4A8B77AD210C509EAA0291A579@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
#include
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@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users