I am assuming you meant :

 

           std::ofstream ifs("container.mob");

boost::archive::text_oarchive ia(ofs); 

 

oa << MyObject;

ofs << std::endl;

 

and not std::ifstream ifs.

 

So if I understand well, this “patch” only adds a newline to the archive at the saving stage.

 

I tried it but it did not help in any way; in fact I cannot see how it could help, since the problem is at the point of the loading of the std::string, not at the end of the load of the whole object. What I mean here is that MyObject is, in my case, a class containing a std::vector of pointers to class containing std::strings. One of these strings is too long, which causes the crash. Maybe what you meant is appending the std::endl after the serialization of the std::string, but this is not possible since at this point I have only access to the archive, not the underlying ofstream :

 

template<class Archive>

void serialize(Archive & ar, const MyClass& m, const unsigned int version)

{          

            ar & m.a_standard_string;

}

 

I do not have access there to the underlying ofstream of the implementation. Note that here, MyObject would contain a std::vector < MyClass * >. And I am serializing directly MyObject which causes the serialization of MyClass later.

 

So, what do you mean? Have you located the bug ?

 


De : boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] De la part de Robert Ramey
Envoyé : jeudi 9 février 2006 04:46
À : boost-users@lists.boost.org
Objet : Re: [Boost-users] [Serialization]: bug while serializing astd:string

 

Untl 1.34 comes out try the following on the output stream

 

           std::ifstream ofs("container.mob");

boost::archive::text_oarchive ia(ofs); 

 

oa << MyObject;

ofs << std::endl;

 

"RIVASSEAU Jean Noel" <JN.RIVASSEAU@oberthurcs.com> wrote in message news:87F60F7FA02FF749AFB02BD9FCAA6B04C87411@naserv31.nanterre.oberthurcs.com...

I have been able to test with a string stream; the bug does not occur.

 

That is, this code produces the bug:

 

            std::ifstream ifs("container.mob");

boost::archive::text_iarchive ia(ifs); 

 

ia & MyObject;

 

while the following does not:

 

            std::ifstream ifs("container.mob");

 

            std::ostringstream tmp;

           

tmp << ifs.rdbuf();

 

            std::istringstream is(tmp.str());

 

boost::archive::text_iarchive ia(is); 

 

ia & MyObject;

 

 

a)       try using a different stream buffer strstream

 

 

So do you have any clue, Robert ?? Clearly the problem has to do with buffering somewhere….

 

Jean-Noël


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users