boost::serialization stream exception

Hi, I encountered a mysterious stream exception when trying to deserialize an std::map<std::string,long> container. The exception seems to occur depending on the data stored in the container. Unfortunately none of the hints regarding stream exceptions from the manual seem to help. The source code is as follows:
std::map<RHANDLE,long> ArchiveEntries; ... void ResArchive::SaveToFile() { std::ofstream ofs (INDEX_FILE_NAME); boost::archive::binary_oarchive OArchive(ofs); OArchive <<ArchiveEntries; } void ResArchive::LoadFromFile() { std::ifstream ifs(INDEX_FILE_NAME); boost::archive::binary_iarchive IArchive(ifs); IArchive >>ArchiveEntries; //STREAM EXCEPTION!!! } <<<< I do not open any file stream to the index file in any other part of my source code, so multiple simultaneous streams can't be the problem. I can consistently reproduce the error for 2 given sets of test data, but I also have some test data ( just 2 entries instead of a few thousand) where the problem does not occur. I have not been able to isolate the exact data that is needed to cause such a stream exception though. Any hints on how to proceed would be greatly appreciated. Thanks in advance for your time! :-) Best Regards, -- Adrian Grigore -- Adrian Grigore adrian@lobstersoft.com Lobstersoft - Fun Brain-Bending Games For All Ages http://www.lobstersoft.com Member of the Association of Shareware Professionals

Adrian Grigore wrote:
I encountered a mysterious stream exception when trying to deserialize an std::map<std::string,long> container. The exception seems to occur depending on the data stored in the container. Unfortunately none of the hints regarding stream exceptions from the manual seem to help. ...
void ResArchive::SaveToFile() { std::ofstream ofs (INDEX_FILE_NAME); boost::archive::binary_oarchive OArchive(ofs); OArchive <<ArchiveEntries; }
void ResArchive::LoadFromFile() { std::ifstream ifs(INDEX_FILE_NAME); boost::archive::binary_iarchive IArchive(ifs); IArchive >>ArchiveEntries; //STREAM EXCEPTION!!! }
Open your streams with 'binary' mode. Jeff Flinn
participants (2)
-
Adrian Grigore
-
Jeff Flinn