also try using strstream as it does no code conversion.
 
If you can make small example that illustrates the problem I would be glad to look at it.
 
Robert Ramey
 
"RIVASSEAU Jean Noel" <JN.RIVASSEAU@oberthurcs.com> wrote in message news:87F60F7FA02FF749AFB02BD9FCAA6B04D27419@naserv31.nanterre.oberthurcs.com...

Hello

 

I have tried to open an archive in text mode with no_codecvt attribute, like this:

 

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

           

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

 

but it still triggers the bug.

 

I do not think the bug is due to something that is not handled in the stream, since I do not have any special characters or stuff like that (except end lines). Plus, the fact that it crashes at the magical number 512 characters get me to think it is more related to a buffer problem, however, you are the specialist.

 

How can I investigate the code conversion facets used by text archive? I  am not familiar at all with locales, or facets, but if you give me some hints about how they are used in the BSL, I may get started.

 

Regards

 

Jean-Noël

 

Ps: everything works fine in XML archive mode, so for my project I have switched to that, but I’d still like to get this bug fixed for the benefits of all…

 


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 17:11
À : boost-users@lists.boost.org
Objet : Re: [Boost-users] [Serialization]: bug while serializingastd::string

 

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" <JN.RIVASSEAU@oberthurcs.com> wrote in message news:87F60F7FA02FF749AFB02BD9FCAA6B04CB28D4@naserv31.nanterre.oberthurcs.com...

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


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


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