Boost serialization problem

Go To StackoverFlow.com

1

i have situation like this:

class IData 
{
  virtual void get() = 0;
  virtual void set() = 0;
}
BOOST_ASSUME_IS_ABSTRACT(IData)
BOOST_EXPORT_CLASS(IData)

template<typename T>
class ConcreteData : public IData
{
public:

protected:
 template<typename Archive>
 void serialize(Archive& ar, const unsigned version)
 {
   ar & data;
 }
private:
 std::vector<T> mData;
}
BOOST_EXPORT_CLASS(ConcreteData<float>)
BOOST_EXPORT_CLASS(ConcreteData<int>)
BOOST_EXPORT_CLASS(ConcreteData<double>)

i want to serialize and deserialize "IData" instances via boost serialization but it seems not working. Has anyone done this before or do you have any suggestions.by the way i am usin VS 2005.

2009-06-16 09:06
by Qubeuc
could we see a bit more code? how is get() / set() implemented in the concrete, where's the data stored - Pieter 2009-06-17 10:49


3

Try using BOOST_CLASS_EXPORT_GUID instead:

BOOST_CLASS_EXPORT_GUID(ConcreteData<float>, "ConcreteData<float>")
BOOST_CLASS_EXPORT_GUID(ConcreteData<int>, "ConcreteData<int>")
2009-06-26 20:55
by Mike
thanks that worked - Qubeuc 2009-06-27 19:21


1

In case your class lives in a namespace, don't forget to add the namespace:

BOOST_CLASS_EXPORT_GUID(NameSpace::ConcreteData<float>, "NameSpace::ConcreteData<float>")
BOOST_CLASS_EXPORT_GUID(NameSpace::ConcreteData<int>, "NameSpace::ConcreteData<int>")
2012-03-29 08:09
by RobW