|
Boost Users : |
From: Juan Quiroz (juancq_at_[hidden])
Date: 2006-05-01 17:10:13
I am trying to serialize a vector of polymorphic pointers. My code looks as
follows:
class ASTNode{
...
protected:
vector <ASTNode*> children;
string name;
string type;
private:
// Code for serialization
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, unsigned int version)
{
ar & name;
ar & type;
ar & children;
}
}
class ASTNode2: public ASTNode{
...
private:
// Code for serialization
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, unsigned int version)
{
// serialize base class information
ar & boost::serialization::base_object<ASTNode>(*this);
}
// End code for serialization
}
I use the vector "children" to hold pointers to both base and derived
objects. I have tried registering the derived classes at the top of the
serialize function call, with the use of
ar.register(static_cast<ASTNode*>(NULL)).
I have also tried using the BOOST_CLASS_EXPORT_GUID macro to register the
classes in main. Yet, I still get a unregistered class exception. Any
guidance would be greatly appreciated.
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