12 May 01:19
in-memory stream, binary archive,serialization
From: Victor Whiskey Yankee <victor.whiskey.yankee <at> gmail.com>
Subject: in-memory stream, binary archive,serialization
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-11 23:20:48 GMT
Subject: in-memory stream, binary archive,serialization
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-11 23:20:48 GMT
Hello,
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.
I am trying to flesh out the two operations marshall() and unmarshall()
below, such that an instance of STORAGE_TYPE
will hold the resulting bytes of an archival operation of a class of
type T, or the inverse where I have the STORAGE_TYPE
and want to create a new T from an oarchive operation.
#include <string>
#include <vector>
#include <sstream>
#ifdef USE_TEXT
typedef std::string STORAGE_TYPE;
#else
typedef std::vector<unsigned char> STORAGE_TYPE;
#endif
template<typename T>
(Continue reading)
RSS Feed