Best way to save/load an object to file?
Bill Baxter
dnewsgroup at billbaxter.com
Mon Jun 23 00:58:39 PDT 2008
Bill Baxter wrote:
> aarti_pl wrote:
>> Saaa pisze:
>>> As the subject says : )
>>>
>>> I could make my own personal loading saving functions of all the
>>> specific variables in the objects, but I'd love there to be an easier
>>> way than that.
>>
>> You may try doost serializer:
>> http://dsource.org/projects/doost/
>>
>> You can serialize to file (generally: different kinds of storages) or
>> to string. There are 2 kinds of archives: simple text archive and JSON
>> archive.
>>
>> See below for use cases:
>> http://dsource.org/projects/doost/browser/trunk/examples/util/serializer/FunctionTest.d
>>
>> http://dsource.org/projects/doost/browser/trunk/examples/util/serializer/FunctionTest1.d
>>
>>
>> Simplest use case for storing in file you can find in FunctionTest1.d
>> - 3rd unit test from top.
>>
>> Currently Phobos only, but should be rather easy to adapt for Tango.
>>
>> BR
>> Marcin Kuszczak
>> (aarti_pl)
>>
>
> Sweet. Thanks for reminding me about that!
> I'm in the market for some serialization code too.
>
> Does it handle references properly? Meaning if I have class objects A
> and B that both refer to the same C, will C only get serialized once?
Just wanted to note here, that after playing with it a bit it does seem
to handle references properly.
It also manages to serialize simple classes without any intrusive
instrumentation whatsoever. Very nice! As usual with doost, though, it
could use a little documentation. And more comments in the code. The
few comments there are in Polish, which isn't much use to me.
I couldn't find the serializer in arclib. What file is it in?
--bb
More information about the Digitalmars-d-learn
mailing list