www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Serialization + semantics of toString

reply aarti_pl <aarti_no_spam_ interia.pl> writes:
Bill Baxter Wrote:

 On Fri, Nov 13, 2009 at 12:13 AM, aarti_pl <aarti_no_spam_ interia.pl> wrote:
 Andrei Alexandrescu Wrote:

 Additionally I would like to mention that there is also great BinaryArchive
from Bill Baxter, which I didn't mention in my first post.

There is? Completely forgot about that. If I recall the big wish list item I had for your serializer was robust subclass handling for things like serializing a BaseClass[] with a mix of pointers to BaseClass and DerivedClass. You need to be able to de-serialize that by saying something like unserialize!(BaseClass[]). I think at the time I tried it, your serializer didn't save enough info to know the proper derived class to load up. --bb

This is still missing. The problem I had is that template functions are not virtual, so I can not get derived class which should be dumped. But I think it can be doable: just needs some more time and thinking. Now typeid() gives type of most derived class, so maybe this is a way?
Nov 13 2009
parent Bill Baxter <wbaxter gmail.com> writes:
On Fri, Nov 13, 2009 at 7:14 AM, aarti_pl <aarti_no_spam_ interia.pl> wrote=
:
 Bill Baxter Wrote:

 On Fri, Nov 13, 2009 at 12:13 AM, aarti_pl <aarti_no_spam_ interia.pl> w=


 Andrei Alexandrescu Wrote:

 Additionally I would like to mention that there is also great BinaryAr=



 There is? =A0Completely forgot about that.

 If I recall the big wish list item I had for your serializer was
 robust subclass handling for things like serializing a BaseClass[]
 with a mix of pointers to BaseClass and DerivedClass. =A0You need to be
 able to de-serialize that by saying something like
 unserialize!(BaseClass[]). =A0I think at the time I tried it, your
 serializer didn't save enough info to know the proper derived class to
 load up.

 --bb

This is still missing. The problem I had is that template functions are n=

ink it can be doable: just needs some more time and thinking. Well, it was definitely possible, even a year ago, because Tom S.'s serializer in xf could do it, though I don't recall how. It was quite complicated. Layers and layers of ctfe code instantiating templates creating more code via ctfe, or something like that.
 Now typeid() gives type of most derived class, so maybe this is a way?

Yeh, definitely seems like that could help. --bb
Nov 13 2009