Re: [Boost-users] problem with serialization of pure virtual
You should send a code snippet. What are the syntax error you get, and the error you get when doing a "BOOST_CLASS_EXPORT(derived);" ? I also have a problem with an abstract base class (although at link time, not compile time). Try removing the pure virtual function (just to see if it works). Another hint too would be to try to serialize a constant member; sometimes I had strange ASSERTION_FAILURE related to serialization of non-constants (this is also explained in the docs). Jean-Noël -----Message d'origine----- De : boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] De la part de Tobias Combe Envoyé : mardi 28 février 2006 13:18 À : boost-users@lists.boost.org Objet : [Boost-users] problem with serialization of pure virtual Hello I read the documention and some prior postings to related topics. But none of the proposed solutions seems to work for me. My problem: I have an abstarct base class(with pure vitual function) and several derived from that. All are written in the same source/header -file. I want to serialize an object via a pointer to the base-class. When i use "ar.register<derived>();" in the template of the base-class to register the derived classes, i get a syntax error. When i export them with "BOOST_CLASS_EXPORT(derived);" or BOOST_CLASS_EXPORT_GUID(derived,"derived") it doesn't work (i think because they are all in the same file). I'm also using "BOOST_IS_ABSTRACT(base);" When i comment "oa << object;" ervything compiles fine. Uncommented i get a: boost/archive/detail/oserializer.hpp:567: error: incomplete type ` boost::STATIC_ASSERTION_FAILURE<false>' does not have member `value' error... So is there a solution (without seperating the derived classes into different files) for this problem? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jean Noel wrote:
You should send a code snippet.
Event.h:
#include
What are the syntax error you get, and the error you get when doing a "BOOST_CLASS_EXPORT(derived);" ?
"syntax error before `;' token" for that line
I also have a problem with an abstract base class (although at link time, not compile time). Try removing the pure virtual function (just to see if it works).
this doesn't help
Another hint too would be to try to serialize a constant member; sometimes I had strange ASSERTION_FAILURE related to serialization of non-constants (this is also explained in the docs)
I'm serializing a constant member...
void Sensor::send(const SENSOR_Event *event){ ... // serialize to string std::stringstream s; boost::archive::text_oarchive oa(s); //SENSOR_Event tmp = *event; const SENSOR_Event tmp = *event; oa << tmp; std::string p = s.str(); ... }
Note that the above change will fix the "problem" . The following would be much better: void Sensor::send(const SENSOR_Event * const event){ // serialize to string std::stringstream s; boost::archive::text_oarchive oa(s); oa << event; std::string p = s.str(); }
participants (3)
-
RIVASSEAU Jean Noel
-
Robert Ramey
-
Tobias Combe