Re: [Boost-users] [Serialization]: bug while serializing a std::string

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"

Sorry I got mixed up with another post.
The main difference between strstream and other streams is that strstream doesn't do any code conversion. This is also consistent with the idea that something in the string isn't being handled in the code conversion facet of the the stream in the expected manner. a couple of ideas would be to investicate the code conversion facets used by the text archive. Also look at the no_codecvt attribute on archive open.
Robert Ramey
"RIVASSEAU Jean Noel"
participants (2)
-
RIVASSEAU Jean Noel
-
Robert Ramey