Op Di, 17 mei, 2011 11:17 am, schreef Thiago Macieira: > On Tuesday, 17 de May de 2011 10:26:39 Andre Somers wrote: >> > That said, I'd much prefer ssize_t to the current int. The 2GB limit >> on >> > 64bit systems would disappear, without impacting 32bit systems. >> >> Then we are back with data exchange issues, are we not? How would a 32 >> bit >> Qt application deal with a data file that contains a list of 2^32 + x >> elements? Or that requires an address space larger than 2^32? > > Well, you have to remember to properly cast the size type to a fixed width > (i.e., not ssize_t). The wire format must be the same, so we must choose > the > 64-bit type. > > That means writing code like this: > stream << qint64(container.size()); > /* stream the elements */ > and > qint64 size; > stream >> size; > container.reserve(ssize_t(size)); > /* read the elements */ > > Of course you cannot load more than 2^32 items into a container on 32-bit, > so > your question is not relevant.
That's the whole point: where in Qt 4, I am sure I am able to load a file that was written with another Qt 4 program, I am not certain anymore of that in this setup. I understand that you can make the wire format always use a 64 bit format. But it means that actually trying to read in such a format may result in crashes. Handling errors in working with QDataStream is tricky enough as it is (basically, impossible, as far as I got with it). How do you suggest we deal with this then? By first manually writing out the number of elements, and then again with the actual container streaming operator? How does a user of the QDataStream API know the limits of what can and can't be read in? For me, that *is* very relevant. I was under the impression that the idea was that the data stored with QDataStream was portable between Qt applications, also on other platforms. It seems to me, that moving to platform dependent sizes for containers would break this behaviour. How are you going to explain to your end user that the application works fine when saving X items, but will crash the reading application when saving Y items? André _______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
