Boost logo

Boost :

From: krempp_at_[hidden]
Date: 2000-11-09 14:20:44


Lately I thought about building a C++ pickle class to bring 'dump' and
'load' features to most c++ objects.
(directly inspired from python's pickle features..)

this would rely on other facilities (streams, binary I/O, .. ) at the
level of basic elements (integrals, floats, pointers, ..)
and have template-recursive definitions for container types, through
partial template specialisation.

and be used like this :
vector<vector<float v> > v; v= ....
pickle pic(myfile);
pic.dump(v);

producing something like that :
vector<vector<f > > {size=6 dat=
 { #0={size=0 dat=
 { }}
 #1={size=1 dat=
 { #0=1.01 }}
 #2={size=2 dat=
 { #0=2.01 #1=2.01 }}
 #3={size=3 dat=
 { #0=3.01 #1=3.01 #2=3.01 }}
 #4={size=4 dat=
 { #0=4.01 #1=4.01 #2=4.01 #3=4.01 }}
 #5={size=5 dat=
 { #0=5.01 #1=5.01 #2=5.01 #3=5.01 #4=5.01 }}
 }
}
(result from a first attempt at implementation of pickle::dump.. )

The key feature of the class is to insure invariance of the object
after dump/load cycles..
The load function is given an object of appropriate type to be filled
(and the type name as first word in the dump allows to check that the
dumped data matches the given object. calling load on the example data
with a vector<vector<double > > would instantly fail (with proper
diagnostic), and that's what I think it should do.

performance (in time-efficiency and space-efficiency) is not my primal
matter.
(although it might be a good thing, to broaden its polyvalence, if
pickle was able to use binary elementary I/O, and a customisable
degree of 'decoration' intended for human-readers. eg printing the
indexes of the elements inside a vector should be a choice, since it
is not necessary for future re-loading)

In a first time I want to reach as primary goals
-polyvalence of usage.
-some form of human-readability (basically, avoiding cryptic symbols
and dump structure, and even providing human-reader some 'decoration'
to help occasional 'manual' reading of dumped objects. )

Is this
a) something that has already been implemented somewhere.
b) something that has some potential but nothing to do with Boost.
C) something utterly useless.
d) something that could fit in Boost.
e) whatever you think it is, and then please do tell..

-- 
Samuel

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