Hi.
To support the serialization of a class I don't want to change anything,
I have added free save and load function. (See the test code below.)
It compiles and appears to work.
I have the following questions:
* Is it OK to put the save & load definitions in a separate
implementation file?
* Is it OK to specify track_never in a cpp file? Will this cause
problems if someone else tries to serialize a map ?
thanks!
- Martin
- global_serialization.h -
// ...
class MyComplexClass;
// ...
namespace boost {
namespace serialization {
// Declare save and load for MyComplexClass
template<class Archive>
void save(Archive & ar, const MyComplexClass& t, unsigned int version);
template<class Archive>
void load(Archive & ar, MyComplexClass& t, unsigned int version);
}
}
// Split:
BOOST_SERIALIZATION_SPLIT_FREE(MyComplexClass);
*****
- complex_class_serialization.cpp -
// ...
#include "ComplexClass.h"
// ...
typedef std::map
ser_map_t m;
// ... fill m object from t object
ar << m; // Serialize
}
template<class Archive>
void load(Archive & ar, CBoxHandler & t, unsigned int version)
{
ser_map_t m;
ar >> m;
// ... init t object from m
}
} // namespace serialization
} // namespace boost