4 ms·
Another similar use for reflection I am waiting for is a way to effortlessly serialize data. Specifically for physics experiments I have several PODs from diffe
by saboot 12y ago
Another similar use for reflection I am waiting for is a way to effortlessly serialize data. Specifically for physics experiments I have several PODs from different acquisition devices. Instead of serializing them all myself, it would be great to just pass them onto a function to do that for me. Also useful because people will inevitably ask "I don't like file format <X>, can you save it as <Y>?".
CERN's ROOT software alleviates some of this issue with their dictionary builder for their own format.
- stinos 12y agoThing is if you go somewhat further than POD you always end up with 'this field should not be serialized' situations so you'd still have to manually add code to indicate that. Though I agree it would be nice just be able to tell 'serialize this struct', it's not really that hard with boost.serialization or similar to declare the serialization functions manually (I don't know how ROOT does it): template< class Archive > void serialize( Archive& ar, POD& pod ) { ar & pod.field1; ar & pod.field2; ar & pod.field3; }
- cozzyd 12y agoROOT does this with its own preprocessor and custom comment decorators. like: class mydata { /* simple type */ int n; /* the following array is of length n */ double * v; //[n] /* don't serialize the following */ int reference_count; //! ClassDef(mydata,1) ; // this macro does some magic, 1 is the version number etc. };
- stinos 12y agoDidn't know that. But after seeing this: I vastly prefer a streams based orientation then. No magic, no comments.