Boost logo

Boost :

Subject: [boost] [serialization] In-memory archive?
From: Ling Li (liling_at_[hidden])
Date: 2008-10-16 17:05:13


Is there an easy way to serialize into a in-memory archive so that an
object can be, say, transferred over a network? Of course one can use
a disk file as the intermediate step but having some in-memory archive
should help here.

Actually, as a related question, is there a way to serialize into and
deserialize from some map-like in-memory archive? Just to illustrate
the idea better, say we have a Point class.

class Point {
    double m_x, m_y;
public:
    Point(double x, double y): m_x(x), m_y(y) {}
};

We can use the constructor Point(1.0, 2.0) to get an object. But how
about if we want to construct a Point object from a std::map that has
"x => 1.0; y=> 2.0" as its key-value pairs? I guess my example is too
simple so that deserializing from a map is not necessary. But consider
deserializing from a database, where one natural way to present the
information is not a long binary string but a list of key-value pairs.
Or consider a generic factory that takes in such a map and gives out a
constructed object.

Note that a map usually doesn't keep entries in order so this may add
extra burden to the serializing code.

Please let me know if what I am looking for is too crazy. Any input is
appreciated.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk