当前位置: 首页>>代码示例>>C++>>正文


C++ QDataStream::byteOrder方法代码示例

本文整理汇总了C++中QDataStream::byteOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ QDataStream::byteOrder方法的具体用法?C++ QDataStream::byteOrder怎么用?C++ QDataStream::byteOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDataStream的用法示例。


在下文中一共展示了QDataStream::byteOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

qint16 readQInt16asLittleEndian(QDataStream &stream)
{
	QDataStream::ByteOrder bo = stream.byteOrder();
	stream.setByteOrder(QDataStream::LittleEndian);
	quint16 res;
	stream >> res;
	stream.setByteOrder(bo);
	return res;
}
开发者ID:forensictool,项目名称:coex,代码行数:9,代码来源:reader.cpp

示例2: readBinaryArray

QVariant readBinaryArray(QDataStream& in, int& position) {
    quint32 arrayLength;
    quint32 encoding;
    quint32 compressedLength;

    in >> arrayLength;
    in >> encoding;
    in >> compressedLength;
    position += sizeof(quint32) * 3;

    QVector<T> values;
    if ((int)QSysInfo::ByteOrder == (int)in.byteOrder()) {
        values.resize(arrayLength);
        QByteArray arrayData;
        if (encoding == FBX_PROPERTY_COMPRESSED_FLAG) {
            // preface encoded data with uncompressed length
            QByteArray compressed(sizeof(quint32) + compressedLength, 0);
            *((quint32*)compressed.data()) = qToBigEndian<quint32>(arrayLength * sizeof(T));
            in.readRawData(compressed.data() + sizeof(quint32), compressedLength);
            position += compressedLength;
            arrayData = qUncompress(compressed);
            if (arrayData.isEmpty() ||
                (unsigned int)arrayData.size() != (sizeof(T) * arrayLength)) { // answers empty byte array if corrupt
                throw QString("corrupt fbx file");
            }
        } else {
            arrayData.resize(sizeof(T) * arrayLength);
            position += sizeof(T) * arrayLength;
            in.readRawData(arrayData.data(), arrayData.size());
        }

        if (arrayData.size() > 0) {
            memcpy(&values[0], arrayData.constData(), arrayData.size());
        }
    } else {
        values.reserve(arrayLength);
        if (encoding == FBX_PROPERTY_COMPRESSED_FLAG) {
            // preface encoded data with uncompressed length
            QByteArray compressed(sizeof(quint32) + compressedLength, 0);
            *((quint32*)compressed.data()) = qToBigEndian<quint32>(arrayLength * sizeof(T));
            in.readRawData(compressed.data() + sizeof(quint32), compressedLength);
            position += compressedLength;
            QByteArray uncompressed = qUncompress(compressed);
            if (uncompressed.isEmpty()) { // answers empty byte array if corrupt
                throw QString("corrupt fbx file");
            }
            QDataStream uncompressedIn(uncompressed);
            uncompressedIn.setByteOrder(QDataStream::LittleEndian);
            uncompressedIn.setVersion(QDataStream::Qt_4_5); // for single/double precision switch
            for (quint32 i = 0; i < arrayLength; i++) {
                T value;
                uncompressedIn >> value;
                values.append(value);
            }
        } else {
            for (quint32 i = 0; i < arrayLength; i++) {
开发者ID:ZappoMan,项目名称:hifi,代码行数:56,代码来源:FBXReader_Node.cpp


注:本文中的QDataStream::byteOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。