Jump to page: 1 2
Thread overview
Best way to save/load an object to file?
Jun 18, 2008
Saaa
Jun 18, 2008
BCS
Jun 20, 2008
Saaa
Jun 19, 2008
Lutger
Jun 20, 2008
Saaa
Jun 22, 2008
aarti_pl
Jun 22, 2008
Saaa
Jun 23, 2008
aarti_pl
Jun 23, 2008
Bill Baxter
Jun 23, 2008
Bill Baxter
Jun 23, 2008
Christian Kamm
Jun 23, 2008
Bill Baxter
Jun 23, 2008
aarti_pl
Jun 27, 2008
Bill Baxter
June 18, 2008
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.


June 18, 2008
Reply to Saaa,

> 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.
> 

It might be possible to generate a generic save device using tuple of and some magic to detect and deal with references (convert them to file references with some caching and delayed output to deal with loops and whatnot)

<joke> I could show you how to do this, but then the knowledge would kill you </joke> 


June 19, 2008
Saaa wrote:

> 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.

If you use Tango, you'll probably want to look into protocols. Haven't used it myself yet, so I can't comment on it. There might be other serialization code around somewhere over at dsource though, arclib used to have some but I believe that makes use of Tango's now.
June 20, 2008
Lol, I think I'm not really that good a magician :)

A box model would suffice I think:
box class 1{
auto colors[]=fruitsClass.colors[];
..
..
}

save box to file
--
load box from file would set all values.

Are there boxes like this?

>
> It might be possible to generate a generic save device using tuple of and some magic to detect and deal with references (convert them to file references with some caching and delayed output to deal with loops and whatnot)
>
> <joke> I could show you how to do this, but then the knowledge would kill you </joke>
> 


June 20, 2008
I could use tango.. wouldn't be that much of a difference. I need to take a deeper look into these things (I've just seen the arclib serializer :). But as mentioned above, a simpler approach would suffice.

>
> If you use Tango, you'll probably want to look into protocols. Haven't
> used
> it myself yet, so I can't comment on it. There might be other
> serialization
> code around somewhere over at dsource though, arclib used to have some but
> I believe that makes use of Tango's now.


June 22, 2008
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)

June 22, 2008
Looks interesting, thanks.
I need to check the code a bit more, but the creating-JSON-archive-part
really strikes my fancy :)
Phobos only wouldn't be a problem for me.
And as I read it, the boost license lets me use the code in compiled form
without having to put the license in text form. Another plus!

>
> 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)
> 


June 23, 2008
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?

--bb
June 23, 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
June 23, 2008
Bill Baxter Wrote:
> I couldn't find the serializer in arclib.  What file is it in?

Maybe Clay or I removed it. It can always be found here: http://www.dsource.org/projects/serialization

It is discontinued though.

Christian

« First   ‹ Prev
1 2