Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-01-16 12:15:01


The following changes would make your classes compatible with all archive
types
and might well fix your problem.

class C : public Serializer
{
typedef Serializer Parent;
public:
std::string text;
A* m_owner;
int32 dasse;
Vector<float> vector_test;

C():m_owner(0)
{
text = "Ola sua puta rabeta!";
dasse = 69;
vector_test.push_back(1);
vector_test.push_back(1.2f);
vector_test.push_back(1.3f);
vector_test.push_back(1.4f);
}

// standard way of specifying serialization for a class
template<class Archive>
serialize(Archive & ar, const unsigned int version){
ar.template register_type<C>();
ar.Serialize(dasse);
ar.Serialize(text);
//ar.Serialize(m_owner);
//ar.Serialize(vector_test);
}

void Serialize(IArchive& ar, const unsigned int version)
{
    // forward to correct function from virtual call
    serialize(ar, version);
}

};

BTW - if you want a virtual function interface to the serialization system
you might want to check out "polymorphic archives" in the documentation.

Robert Ramey


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