Writing Classes to File

Kyle Furlong kylefurlong at gmail.com
Mon May 8 12:15:20 PDT 2006


Brad Anderson wrote:
> Jeremy wrote:
>> Is there a way I can just write a whole class to a file?
>>
>> For example, why can't I do:
>>
>> file.writeExact(someClass, someClass.sizeof);
>>
>> This seems to just write 4 bytes, which must be the pointer.
>>
>> The compiler complains when I do this:
>>
>> file.writeExact(*someClass, (*someClass).sizeof);
>>
>> Saying that '*' is only used infront of pointers -- but aren't class always
>> represented with pointers?
>>
>> Anyway, I want to save a class to file, so I can load it back. I was hoping
>> there was a way to do this without having to write/read each element of the
>> class seperately.
>>
>>
> 
> Would Mango's pickling mechanism work here?
> 
> http://www.dsource.org/projects/mango
> 
> http://mango.dsource.org
> 
> 
> BA

Mango's solution is invasive, but for that technique, very well developed.

-- 
Kyle Furlong // Physics Undergrad, UCSB

"D is going wherever the D community wants it to go." - Walter Bright



More information about the Digitalmars-d mailing list