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


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

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


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

示例1: writeVector

void writeVector(QDataStream& out, char ch, QVector<T> vec) {
    // Minimum number of bytes to consider compressing
    const int ATTEMPT_COMPRESSION_THRESHOLD_BYTES = 2000;

    out.device()->write(&ch, 1);
    out << (int32_t)vec.length();

    auto data { QByteArray::fromRawData((const char*)vec.constData(), vec.length() * sizeof(T)) };

    if (data.size() >= ATTEMPT_COMPRESSION_THRESHOLD_BYTES) {
        auto compressedDataWithLength { qCompress(data) };

        // qCompress packs a length uint32 at the beginning of the buffer, but the FBX format
        // does not expect it. This removes it.
        auto compressedData = QByteArray::fromRawData(
            compressedDataWithLength.constData() + sizeof(uint32_t), compressedDataWithLength.size() - sizeof(uint32_t));

        if (compressedData.size() < data.size()) {
            out << FBX_PROPERTY_COMPRESSED_FLAG;
            out << (int32_t)compressedData.size();
            out.writeRawData(compressedData.constData(), compressedData.size());
            return;
        }
    }

    out << FBX_PROPERTY_UNCOMPRESSED_FLAG;
    out << (int32_t)0;
    out.writeRawData(data.constData(), data.size());
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:29,代码来源:FBXWriter.cpp

示例2: write

void Frame::write(QDataStream &stream)
{
    QByteArray lenbuf;

    if (!encodeLength(lenbuf, _data.size()))
    {
        qCritical("qmqtt: Control packet bigger than 256 MB, dropped!");
        return;
    }

    stream << (quint8)_header;
    if(_data.size() == 0) {
        stream << (quint8)0;
        return;
    }
    if (stream.writeRawData(lenbuf.data(), lenbuf.size()) != lenbuf.size())
    {
        qCritical("qmqtt: Control packet write error!");
        return;
    }
    if (stream.writeRawData(_data.data(), _data.size()) != _data.size())
    {
        qCritical("qmqtt: Control packet write error!");
    }
}
开发者ID:ve7mjc,项目名称:qmqtt,代码行数:25,代码来源:qmqtt_frame.cpp

示例3: writeIconToCache

bool IconCacheCreator::writeIconToCache(QDataStream &out, const QFileInfo &fileInfo) {
    QFile in(fileInfo.absoluteFilePath());

    if (!in.open(QIODevice::ReadOnly)) {
        return false;
    }

    char buf[4096];

    QDataStream inStream(&in);

    qint64 size = in.size();
    out.writeRawData((const char *)&size, sizeof(qint64));

    while (!inStream.atEnd()) {
        out.writeRawData(buf, inStream.readRawData(buf, 4096));
    }

    in.close();

    //QPixmap pixmap(f.absoluteFilePath());
    //out << pixmap;
    //out << null;
    //QIcon iconFile(f.absoluteFilePath());
    //out << iconFile;
    //out << null;
    //DPRINT("cache icon: %s", qPrintable(f.absoluteFilePath()));
    return true;
}
开发者ID:chris-magic,项目名称:studycode,代码行数:29,代码来源:IconCacheCreator.cpp

示例4:

/** Erases loaded data from memory */
PwHeaderV3::ErrorCode PwHeaderV3::write(QDataStream& outStream) {
    outStream << SIGNATURE_1 << SIGNATURE_2 << flags << DB_VERSION;
    outStream.writeRawData(masterSeed.constData(), masterSeed.size());
    outStream.writeRawData(initialVector.constData(), initialVector.size());
    outStream << groupCount << entryCount;
    outStream.writeRawData(contentHash.constData(), contentHash.size());
    outStream.writeRawData(transformSeed.constData(), transformSeed.size());
    outStream << transformRounds;
    return SUCCESS;
}
开发者ID:piotrkubisa,项目名称:keepassb,代码行数:11,代码来源:PwDatabaseV3.cpp

示例5: write

void Frame::write(QDataStream &stream)
{
    QByteArray lenbuf;
    stream << (quint8)_header;
    if(_data.size() == 0) {
        stream << (quint8)0;
        return;
    }
    encodeLength(lenbuf, _data.size());
    stream.writeRawData(lenbuf.data(), lenbuf.size());
    stream.writeRawData(_data.data(), _data.size());
}
开发者ID:Vortex375,项目名称:qmqtt,代码行数:12,代码来源:qmqtt_frame.cpp

示例6: iter

template<typename T> void storeBulk(const RawConverter& converter, QDataStream& stream, StreamConnector *streamconnector, const BoundingBox& box, const IRasterCoverage& raster){
    quint64 count = streamconnector->position();
    if ( streamconnector->isFileBased()){
        const UPGrid& grid = raster->grid();
        quint32 blockCount = grid->blocks();
        stream << blockCount;
        for(quint32 i = 0; i < blockCount; ++i){
            const char * data = grid->blockAsMemory(i, false);
            quint64 blockSize = 8 * grid->blockSize(i);
            stream << i;
            stream << blockSize;
            stream.writeRawData(data, blockSize);
        }
        streamconnector->flush(true);
    }else {
        PixelIterator iter(raster, box);
        while(iter != iter.end()){
            if ( count >= STREAMBLOCKSIZE - 9 ) {
                streamconnector->flush(false);
                count = 0;

            }
            count += sizeof(T);
            stream << (T)converter.real2raw(*iter);
            ++iter;
        }
    }
}
开发者ID:karolyiar,项目名称:IlwisConnectors,代码行数:28,代码来源:rasterserializerv1.cpp

示例7: writeMaskList

void MaskChan::writeMaskList(QDataStream& dataOut, QList<MaskRay*>& list)
{
    for (int i=0;i<list.size();i++) {
        dataOut.writeRawData( (const char *)&(list[i]->skipCount), sizeof(long));
        long pairListSize=list[i]->endList.size();
        dataOut.writeRawData( (const char *)&pairListSize, sizeof(long));
        //qDebug() << "skip=" << list[i]->skipCount << " pairs=" << pairListSize;
        for(int j=0;j<list[i]->endList.size();j++) {
            long start=list[i]->startList[j];
            dataOut.writeRawData( (const char *)&start, sizeof(long));
            long end=list[i]->endList[j];
            dataOut.writeRawData( (const char *)&end, sizeof(long));
            //qDebug() << "start=" << start << " end=" << end;
        }
    }
}
开发者ID:Vaa3D,项目名称:v3d_external,代码行数:16,代码来源:MaskChan.cpp

示例8: out

ContestantConnection::ContestantConnection ( ServerNetwork* sn, QTcpSocket* socket ) : QObject ( sn ) {
	m_snet = sn;
	m_answer_capable = true;
	m_hdr = NULL;
	m_authenticated = false;
	m_socket = socket;
	connect ( m_socket, SIGNAL ( error ( QAbstractSocket::SocketError ) ),
	          this, SLOT ( error ( QAbstractSocket::SocketError ) ) );
	connect ( m_socket, SIGNAL ( readyRead() ), this, SLOT ( ready() ) );
	connect ( m_socket, SIGNAL ( disconnected() ), this, SLOT ( disconnected() ) );
	// reply to client of the now established connection
	QByteArray block;
	QDataStream out ( &block, QIODevice::WriteOnly );
	out.setVersion ( QDataStream::Qt_4_5 );
	// construct the header
	p_header hdr;
	hdr.length = sizeof ( ushort );
	hdr.command = NET_CONNECTION_RESULT;

	out.writeRawData ( ( const char* ) &hdr, sizeof ( p_header ) );
	out << ( ushort ) true;

	m_socket->write ( block );
	m_socket->flush();

	m_qnum = m_snet->getQNumber();
	m_qtime = m_snet->getQTime();
	m_qstatus = m_snet->getQStatus();
}
开发者ID:trigger-happy,项目名称:Cerberus,代码行数:29,代码来源:contestant_connection.cpp

示例9: stream

QByteArray IQSMPPOptionalParameter<QString>::encode() const
{
    QByteArray result;
    //Если не устанавливали значения для данной опции, то вернем пустой массив, т.к. данная опция
    //не используется
    if (!_valueSets)
        return result;

    if (tag() == IQSMPP::UndefinedOptionalParameter)
        return result;
    if (maxLength() == 0)
        return result;

    QDataStream stream (&result, QIODevice::WriteOnly);
    stream << (quint16) tag();
    stream << (quint16) 0;

    //Запишим данные
    //Если это строка
    QByteArray stringBA = _value.toLatin1();
    const char * stringShar = stringBA.constData();
    int stringLength = stringBA.length();
    stream.writeRawData(stringShar, stringLength);
    if (_cOctetString)
        stream << (quint8)0x00;

    //Сохраним размер
    stream.device()->seek(2);
    stream << (quint16) result.size() - 4;

    return result;
}
开发者ID:0x6368656174,项目名称:iqSmsSender,代码行数:32,代码来源:iqsmppoptionalparameter.cpp

示例10: writeData

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int AvizoUniformCoordinateWriter::writeData(QDataStream& out)
{
  QString start("@1\n");
  out << start;
  if(true == m_WriteBinaryFile)
  {
    out.writeRawData(reinterpret_cast<char*>(m_FeatureIds), m_FeatureIdsPtr.lock()->getNumberOfTuples() * sizeof(int32_t));
  }
  else
  {
    // The "20 Items" is purely arbitrary and is put in to try and save some space in the ASCII file
    int64_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples();
    int count = 0;
    for (int64_t i = 0; i < totalPoints; ++i)
    {
      out << m_FeatureIds[i];
      if(count < 20)
      {
        out << " ";
        count++;
      }
      else
      {
        out << "\n";
        count = 0;
      }
    }
    // Pick up any remaining data that was not written because we did not have 20 items on a line.
    out << "\n";
  }
  return 1;
}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:35,代码来源:AvizoUniformCoordinateWriter.cpp

示例11: writeCatesToCache

bool IconCacheCreator::writeCatesToCache(QDataStream &out, const QList<QString> &cates) {
    for (int i = 0; i < cates.size(); i++) {
        //out << qPrintable(cates.at(i));
        out.writeRawData(qPrintable(cates.at(i)), cates.at(i).size() + 1);
    }

    return true;
}
开发者ID:chris-magic,项目名称:studycode,代码行数:8,代码来源:IconCacheCreator.cpp

示例12: serializeString

void ClientMessage::serializeString(const QString &string, QDataStream &stream){
    //serializeByteArray(QByteArray(str.toStdString().c_str()), stream);

    //serializeByteArray(str.toUtf8(), stream);
    QByteArray dataArray = string.toUtf8();
    stream.writeRawData(dataArray.data(), dataArray.size());

    stream << quint8('\0'); // NUL TERMINATED
}
开发者ID:elieserdejesus,项目名称:JamTaba,代码行数:9,代码来源:ClientMessages.cpp

示例13: writeSizeToCache

bool IconCacheCreator::writeSizeToCache(QDataStream &out, const QList<int> &sizes) {
    for (int i = 0; i < sizes.size(); i++) {
        //out << sizes.at(i);
        DPRINT("size: %d", out.device()->size());
        out.writeRawData((const char *)&(sizes.at(i)), sizeof(int));
        DPRINT("size: %d", out.device()->size());
    }

    return true;
}
开发者ID:chris-magic,项目名称:studycode,代码行数:10,代码来源:IconCacheCreator.cpp

示例14: serializeDynamicData

void QVRVNCViewer::serializeDynamicData(QDataStream& ds) const
{
    ds << _vncWidth << _vncHeight;
    ds << _vncDirtyRectangles;
    for (int i = 0; i < _vncDirtyRectangles.size(); i++) {
        QRect r = _vncDirtyRectangles[i];
        for (int y = r.y(); y < r.y() + r.height(); y++) {
            ds.writeRawData(reinterpret_cast<const char *>(&_vncFrame[y * _vncWidth]),
                    r.width() * sizeof(unsigned int));
        }
    }
}
开发者ID:ill-look-later,项目名称:qvr,代码行数:12,代码来源:qvr-vncviewer.cpp

示例15: ShortSave

/** Save a QByteArray to a stream with only one leading byte instead of 4. */
void ShortSave (QDataStream &s, const QByteArray &str )
{
  if( str.size() > 255 )
    {
      qWarning( "ShortSave will truncate QByteArray to 255 characters!" );
    }

  quint8 len;
  len = qMin(str.size(), 255);
  s << len;
  s.writeRawData( str.data(), len );
}
开发者ID:Exadios,项目名称:Cumulus,代码行数:13,代码来源:filetools.cpp


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