The QDataStream docs give examples on serializing for compatible formats across versions defined by QDataStream:
<http://doc-snapshot.qt-project.org/qdoc/qdatastream.html#setVersion> Other examples on the web are similar, like: <http://doc.qt.digia.com/qq/qq05-achtung.html> The recommendation is something like: //--------------- //... QDataStream out(&file); // Write a header with a "magic number" and a version out << (quint32)0xA0B0C0D0; out << (qint32)123; //--------------- Then, reading in is: //--------------- //...- QDataStream in(&file); // Read and check the header quint32 magic; in >> magic; if (magic != 0xA0B0C0D0) return XXX_BAD_FILE_FORMAT; // Read the version qint32 version; in >> version; //--------------- QUESTION #1: Is it safe to write the 32-bit magic-number before reading-and-setting the "QDataStream::version()" ? It seems like these examples are not cross-platform, as the 32-bit value may have varying formats on different platforms. Other reading suggests that it is "safe" to assume "QDataStream::version()" wholly fits into an 8-bit value, so this should not be a problem with that value. QUESTION #2: Is it forever safe to assume an 8-bit value is sufficient to store "QDataStream::version()"? Because of my concern regarding "#1", it seems like four "magic-quint8" values should be serialized instead of one "magic-quint32" value. Or, am I just paranoid? --charley P.S.: I'll close with the quote from the Digia page above because I found it funny: "We have two choices, either to attack I/O now and get it over with, or to postpone I/O until near the end. Neither prospect is very attractive." -- Donald E. Knuth _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest