Writing Classes to File (zlib)

Jeremy Jeremy_member at pathlink.com
Tue May 9 06:46:59 PDT 2006


>>
>>Interesting... so could this be done:
>>
>>file.writeExact(someClass, someClass.classinfo.init.length);
>>
>>to write the entire class to a file? (I'd like to do some zlib compression on it
>>too :-D )
>>
>>

OK, so I am able to write the class to file. However, I am writing many objects
of the same class to a file and I want to pass it through some compression. What
is the best way to do this?

1) Should I allocate memory the size of all my objects, writeExact all my
objects to that memory space, and then use zlib compression on that memory
space?

2) or write everything to the file, then ZIP up the file?

3) or zlib compress each object's data before writing to the file? (e.g. if I
was saving 10 objects, I'd do 10 individual zlib compressions and writes) --
would this result in the same space usage as option (1)?





More information about the Digitalmars-d mailing list