Cerealed v0.2.0 - a(nother) D serialisation library
Atila Neves
atila.neves at gmail.com
Wed Nov 20 09:26:37 PST 2013
> assert(foo2.a[1] == 10); // will this pass?
Ah, I see. No, it won't. Which answers the other question about
serialising references to objects. I'm told this is a common
problem, but this being my first bash at a serialisation
library...
I was certain that Orange would be more mature and handle more
corner cases than this library (or else it wouldn't be considered
for inclusion in the std lib), but I wanted to share it since it
works for what I'm doing, does things a bit differently and does
what I need. Also, it was fun coding it.
If anything, if you think some of these ideas are worth it, feel
free to use them. I'm just glad to not have to write the same old
bit twiddling code for networking headers again!
> Even if you know the identifier in the header file you need a
> static type when deserializing:
>
> decerealiser.value!(Foo)
>
> Even if you can instantiate the right subclass you need to have
> the static type information to deserialize it.
>
> It is possible to do, as I have done in Orange. The requirement
> is to register the subclasses that need to be serialized
> through a base class reference. See
> https://github.com/jacob-carlborg/orange/blob/master/orange/serialization/Serializer.d#L241..L262
> and
> https://github.com/jacob-carlborg/orange/blob/master/orange/serialization/Serializer.d#L787..L788
True, I thought of doing something like it to simplify my MQTT
broker implementation but ended up deciding against it.
More information about the Digitalmars-d-announce
mailing list