|
Boost Users : |
From: Sam Contapay (sam_at_[hidden])
Date: 2005-10-21 00:37:18
Sorry I tried to post this through the newsserver gateway. I didn't see the
message show up after half and hour so I'm assuming it didn't post correctly
as this email address wasn't subscribed. I apologize if it does
----------ORIGINAL EMAIL---------------- I've been trying to get loading
from an archive to work for a couple of hours now. Maybe I'm missing
something so I can use anyones "eyes" for help.
This is a program written using VC7.1 and I do have RTTI on. I am able to
save data from a MAP file to an ASCII text file using the serialize
functions, but I'm having a problem getting that information back into my
object. Here are some relevant code snippets if anyone can point me in the
right direction it would be really appreciated. Also is their an archive
that I can search? This news group is only leting me download like 100
messages.
main class with serialize
private:
std::map<std::string, int> WordMapA;
std::map<std::string, int> WordMapB;
friend class boost::serialization::access; template <class Archive> void
serialize(Archive & ar, const unsigned int version) { ar & WordMapA; ar &
WordMapB; }
Now here is my save and load
save:
// Save the bayes filter especially the map for later use std::ofstream
ofs("BayesFilter.stb"); boost::archive::text_oarchive outarchive(ofs);
outarchive << this; ofs.close();
load:
std::ifstream ifs("BayesFilter.stb");
boost::archive::text_iarchive ia(ifs);
CObjTest test;
ia >> test;
ifs.close();
When I save the file it saves to an ASCII file with no problems. When I then
try to load the archive back all the Map data variables are still 0 after a
call to the load function. I poured over the demo and its pretty much word
for word so I don't know whats wrong any help... thanks.
Sam
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