12 May 17:14
Re: in-memory stream, binary archive,serialization
From: Victor Whiskey Yankee <victor.whiskey.yankee <at> gmail.com>
Subject: Re: in-memory stream, binary archive,serialization
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-12 15:14:26 GMT
Subject: Re: in-memory stream, binary archive,serialization
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-12 15:14:26 GMT
Matthias Troyer wrote:
iostreams documentation is so difficult I could not figure it out.
I would have thought that in-memory iostreams would be a standard part of that lib, but obviously not...
I must be the only one that does not want to use file i/o. Jeez.
Anyway, I finally got it to work in-memory with binary archives using the ios::binary arg to stringstream, like this...
std::ostringstream ss(std::ios::out|std::ios::binary);
boost::archive::binary_oarchive oa(ss);
oa << myObj;
I don't know how efficient it is. If anyone knows of a better way I sure would like to see the code.
Thanks,
Vic
On 12 May 2008, at 01:20, Victor Whiskey Yankee wrote:The posting I mentioned above suggests the same thing. As I said, I did try for several hours, but theHello, I need to serialize into and from a memory buffer using boost::archive::binary_oarchive and binary_iarchive. Using std::stringstream does not work (it does work with text_oarchive and text_iarchive in memory and using files). I found a mention in the archives about similar need here: http://lists.boost.org/boost-users/2007/10/31580.php But I cannot figure it out.Have you tried using the Boost IO Stream library to create a stream that buffers in memory and use that with a binary archive?
iostreams documentation is so difficult I could not figure it out.
I would have thought that in-memory iostreams would be a standard part of that lib, but obviously not...
I must be the only one that does not want to use file i/o. Jeez.
Anyway, I finally got it to work in-memory with binary archives using the ios::binary arg to stringstream, like this...
std::ostringstream ss(std::ios::out|std::ios::binary);
boost::archive::binary_oarchive oa(ss);
oa << myObj;
I don't know how efficient it is. If anyone knows of a better way I sure would like to see the code.
Thanks,
Vic
_______________________________________________ Boost-users mailing list Boost-users <at> lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
RSS Feed