|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-04-30 12:07:02
Joseph Hosteny wrote:
> Thanks for the response. I'd have continued the thread, but I didn't
> get the original emails from the list to reply to.
>
> I tried an explicit registration, with the same results. Also, I did
> step into the code where the EXPORT macros were being called, and I
> verified that the pertinent classes were registered in the
> boost::serialization::detail::ktmap, at least (not sure about the
> tkmap). It seems like it just doesn't find the class in the
> oserialization file where the exception is thrown.
>
> The serialization is invoked in a const public class method, via "oa
> << this;" Is there anything tricky you might be aware of that could
> cause the type comparisons to fail? Could I potentially be missing
> something in my class?
I would be curious as to the context in which one would use:
oa << this;
I don't know that its relevant. But off hand I can't see why anyone
would ever want to do this rather than
oa << x where x is the thing we want to save.
> Unfortunately, the project is quite large and it'd fairly difficult
> to strip out everything and add it back in incrementally.
Which of course makes it almost impossible for me to be of
much help. If its a big project, you might try the following.
a) create a small test program. This program would include
the class declarations for all your classes which include serializaition.
b) invoke serialization on each one of your classes.
So the result would look like:
#include <boost/archive/text_archive.hpp>
#include "my_class_a.hpp"
#include "my_class_b.hpp"
...
int
main(int argc, char * argv[]){
my_class_a a_out, a_in;
my_class_b b_out, b_in;
{
std::fostream ofs("test");
boost::archive::text_oarchive oa(ofs);
oa << a_out;
oa << b_out;
...
}
{
std::fistream ifs("test");
boost::archive::text_oarchive ia(ifs);
oa >> a_in;
oa >> b_in;
...
}
assert(a_in == a_out);
assert(b_in == b_out);
...
}
c) If some code re-factoring has to be done in order to make a test like the
above, I would recommend that you just bite the bullet and do it. It
will make your project much easier to develope and much more likely
to be correct. In fact, you might make a test like the above for each
one of your classes - take a look at how the serialization library tests
are set up.
d) I don't remember what your environment is - compiler, os, standard
library, DLLS yes/no etc. So you might want to remind me again.
Robert Ramey
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