Re: how to store list of varying types
Hi G,
I can't argue with your points, but I'd have to do some testing to agree
with the idea that it is that much more efficient. Perhaps if OP is writing
a ton of data, but I've written out files with over 100K significantly
appointed XML records in about 5 seconds.
You are right that a parser to read the file is more trouble (unless you
consider the format to be very rigid), but writing XML is trivial and can be
done with CStdioFile WriteStrings() with a little CString formatting.
It's nice to have different options though. So long as none of the options
is using the built in Serialize stuff. I avoid that these days at all
costs. Too difficult to maintain across version (of course tagged binary has
the same problem of versioning. If I were to use Joe's example, I'd add a
header record with some information about the version.
Tom
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message
news:%234XQQj12IHA.2348@TK2MSFTNGP06.phx.gbl...
"Tom Serface" <tom.nospam@camaswood.com> ha scritto nel messaggio
news:C3E60DCF-F8DD-4379-A9E6-830380189A5E@microsoft.com...
Why not just write out real XML? It makes it easier to test, read, and
even modify outside your program. You'd need a special routine to read
either type of file.
Hi Tom,
I agree with you that "real XML" is easier to test, read and modify, being
a text-based clear format.
However, I think that the main advantage of "tagged binary" [*] over "real
XML" is *efficiency*.
In fact, I believe that reading and writing (especially reading) in
"tagged binary" is much faster and consumes less memory than real XML.
(for example, in real XML you have to escape characters like < > &, etc.
parsing work is much more complicated, etc.
To manage XML it is better to use an external parser like TinyXML or
XMLLite, the latter being COM based, so not very easy... instead it is
trivial to write some C/C++ code to manage "tagged binary".)
[*] I used "tagged binary" in several times, I think it is very intuitive
to think about a format like that. I just did not know that name :)
Giovanni