serialization library
Bill Baxter
dnewsgroup at billbaxter.com
Wed Nov 8 20:05:19 PST 2006
Walter Bright wrote:
> Bill Baxter wrote:
>> How do you fix it? Very simple really. Just store the file as a
>> series of chunks with fixed length headers, and each header contains
>> the length of the data in that chunk. If you get a chunk header with
>> a tag you don't understand, just ignore it. A particular chunk can
>> have sub-chunks too.
>
> Evolution of a file format:
>
> 1.0: Just spew the struct contents out into a file using something like
> fwrite().
>
> 2.0: Oops! Need to update 1.0 and retain backwards compatibility.
> Solution: 2.0 files put out 'illegal' values into the 1.0 format to
> signal it's a 2.0 file.
>
> 3.0: Doh! Find another set of illegal 2.0 values. This time, get smarter
> and have another field with a version number in it.
>
> 4.0: Get smart and implement your suggestion, so you can have both
> backwards and *forwards* compatibility.
>
> Think I'm joking? Just look at a few! Everyone learns this the hard way.
I guess I'm no exception. ;-) I've been through the 4 step program a
few times myself.
> Me, if practical, I like file formats to be in ascii so I can examine
> them easily to see if they're working right.
That is one thing I do like about boost::serialization. With basically
one line of code I can switch between xml serialization and binary
serialization. Only thing I didn't like was I couldn't figure out how
to keep some things binary.
--bb
More information about the Digitalmars-d-announce
mailing list