[serialization] non-intrusive serialization problem
Hi. I have problems defining a non-instrusive serialization of a class. Ive defined the following functions: namespace boost { namespace serialization { template<class Archive> inline void save( Archive & ar, const CLITimeStamp & t, const unsigned int /* file_version */ ){ std::string aux = std::string(t.get14LengthRepresentation()); ar & aux; } template<class Archive> inline void load( Archive & ar, const CLITimeStamp & t, const unsigned int /* file_version */ ){ std::string aux; ar & aux; t = CLITimeStamp((char*)aux.c_str()); } template<class Archive> inline void serialize( Archive & ar, const CLITimeStamp & t, const unsigned int file_version ){ split_free(ar, t, file_version); } }} According to the doc Ive read, this is the way to declare that the class 'CLITimeStamp' can be serialized. Howerver, when I try to do this: template<class Archive> void load(Archive & ar, const unsigned int version){ ar & minDate }; where minDate is a CLITimeStamp pointer, i get the follwing error: <'serialize' is not a Member of CLITimeStamp> Any ideas of what i could be doing wrong? Thanks Federico __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Try the following changes: Federico Feller wrote:
Hi. I have problems defining a non-instrusive serialization of a class. Ive defined the following functions:
namespace boost { namespace serialization {
template<class Archive> inline void save( Archive & ar, const CLITimeStamp & t, const unsigned int /* file_version */ ){ std::string aux = std::string(t.get14LengthRepresentation()); ar & aux; }
template<class Archive> inline void load( Archive & ar, const CLITimeStamp & t, // can't be const as its going to be changed!!! remove const const unsigned int /* file_version */ ){ std::string aux; ar >> aux; t = CLITimeStamp((char*)aux.c_str()); }
template<class Archive> inline void serialize( Archive & ar, const CLITimeStamp & t, // can't be const as its going to be changed!!! remove const const unsigned int file_version ){ split_free(ar, t, file_version); }
}}
participants (2)
-
Federico Feller
-
Robert Ramey