Hi Petr,
For a conversion QByteArray -> qint64 I’m using QByteArray::toLongLong() because there is nothing to convert raw bytes into qint64 but in the Qt specs is written that qlonglong is actually the same as qint64. So this should work.
I think that if the docs say that qlonglong is the same as qint64, then we could assume that is always so, or there will be a bug in Qt ;-)
Possible problem (or maybe not) is that in the BDecoderTest I’m using std::numeric_limits::max() and std::numeric_limits::max() ti get min/max values but std::numeric_limits is a standard template and I don’t know whether there will be a specialization for qint64 on every platform (in gcc 4.1 @ 32b it is present). I’ve looked at the Qt header files and qint64 is there a typedef for __int64 (Windows) or long long (other systems) but that’s implementation specific. So I don’t know whether this piece of code will work everywhere and thus whether it’s a protable solution or not (I’m afraid it’s not).
That got me thinking at first, but then I realized that it should always work and if it doesn’t, then it would be a bug in Qt. For each platform and compiler, which Qt supports, a mapping (typedef) is defined from each of the q-types to the “native” types, and I think that the standard should require each compiler to provide numeric_limits specializations for each “native” type, so I wouldn’t expect that there will be any problem. It is great you are thinking about such issues though!
Best regards,
Peter
