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


C++ QBuffer::write方法代码示例

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


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

示例1: addString

bool HttpMultiContentIO::addString(const QString &string, 
    bool prefixBoundary) {

    if (!d_ptr->isDeviceOpen) {
        qWarning() << "HttpMultiContentIO::" << __FUNCTION__ << 
            "called when device is not open yet";
        return false;
    }

    if(d_ptr->bytesSent > 0) {
        qWarning() << "Already sent " << d_ptr->bytesSent << " bytes";
        return false;
    }

    QBuffer *buff = new QBuffer(this);
    if (!buff->open (openMode())) {
        IODEVICE_ERROR("Could not open buffer in required mode");
    }

    if((prefixBoundary) && (!d_ptr->boundaryString.isEmpty())) {
        buff->write("--");
        if(buff->write(d_ptr->boundaryString.toUtf8()) == -1) {
            IODEVICE_ERROR("Write to buffer failed")
        }

        buff->write("\r\n");
    } else if(prefixBoundary) {
开发者ID:arcean,项目名称:webupload-engine,代码行数:27,代码来源:httpmulticontentio.cpp

示例2: file

void
StationsPluginSimple::saveDiskCache()
{
  QDomDocument doc;
  QFile file(diskCache());
  QBuffer buffer;

  buffer.open(QIODevice::ReadWrite);

  buffer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  buffer.write("<cache>\n");
  buffer.write(" <stations>\n");

  foreach (Station *station, stations) {
    QString data =
      "  <station id=\"%1\">\n"
      "   <name>%2</name>\n"
      "   <description>%3</description>\n"
      "   <latitude>%4</latitude>\n"
      "   <longitude>%5</longitude>\n"
      "  </station>\n";

    buffer.write(data.arg(station->id())
	       .arg(station->name())
	       .arg(station->description())
	       .arg(station->pos().x())
	       .arg(station->pos().y())
	       .toUtf8());
  }
开发者ID:iksaif,项目名称:lugdulov,代码行数:29,代码来源:stationspluginsimple.cpp

示例3:

bool QInstaller::VerboseWriter::flush(VerboseWriterOutput *output)
{
    stream.flush();
    if (logFileName.isEmpty()) // binarycreator
        return true;
    if (!preFileBuffer.isOpen())
        return true;
    //if the installer installed nothing - there is no target directory - where the logfile can be saved
    if (!QFileInfo(logFileName).absoluteDir().exists())
        return true;

    QString logInfo;
    logInfo += QLatin1String("************************************* Invoked: ");
    logInfo += currentDateTimeAsString;
    logInfo += QLatin1String("\n");

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    buffer.write(logInfo.toLocal8Bit());
    buffer.write(preFileBuffer.data());
    buffer.close();

    if (output->write(logFileName, QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text, buffer.data())) {
        preFileBuffer.close();
        stream.setDevice(nullptr);
        return true;
    }
    return false;
}
开发者ID:qtproject,项目名称:installer-framework,代码行数:29,代码来源:utils.cpp

示例4: writeMapping

QByteArray FSTReader::writeMapping(const QVariantHash& mapping) {
    static const QStringList PREFERED_ORDER = QStringList() << NAME_FIELD << TYPE_FIELD << SCALE_FIELD << FILENAME_FIELD
    << TEXDIR_FIELD << JOINT_FIELD << FREE_JOINT_FIELD
    << BLENDSHAPE_FIELD << JOINT_INDEX_FIELD;
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    
    for (auto key : PREFERED_ORDER) {
        auto it = mapping.find(key);
        if (it != mapping.constEnd()) {
            if (key == FREE_JOINT_FIELD) { // writeVariant does not handle strings added using insertMulti.
                for (auto multi : mapping.values(key)) {
                    buffer.write(key.toUtf8());
                    buffer.write(" = ");
                    buffer.write(multi.toByteArray());
                    buffer.write("\n");
                }
            } else {
                writeVariant(buffer, it);
            }
        }
    }
    
    for (auto it = mapping.constBegin(); it != mapping.constEnd(); it++) {
        if (!PREFERED_ORDER.contains(it.key())) {
            writeVariant(buffer, it);
        }
    }
    return buffer.data();
}
开发者ID:cozza13,项目名称:hifi,代码行数:30,代码来源:FSTReader.cpp

示例5: redirect

void Response::redirect(const QUrl &url, quint16 status)
{
    Q_D(Response);
    d->location = url;
    setStatus(status);
    if (url.isValid() && !d->body) {
        QBuffer *buf = new QBuffer;
        if (!buf->open(QIODevice::ReadWrite)) {
            qCCritical(CUTELYST_RESPONSE) << "Could not open QBuffer to write redirect!" << url << status;
            delete buf;
            return;
        }
        buf->write(QByteArrayLiteral("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0"
                                     "Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
                                     "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
                                     "  <head>\n"
                                     "    <title>Moved</title>\n"
                                     "  </head>\n"
                                     "  <body>\n"
                                     "     <p>This item has moved <a href="));
        buf->write(url.toEncoded());
        buf->write(QByteArrayLiteral(">here</a>.</p>\n"
                                     "  </body>\n"
                                     "</html>\n"));
        d->body = buf;
        d->headers.setContentType(QStringLiteral("text/html; charset=utf-8"));
    }
}
开发者ID:zackxue,项目名称:cutelyst,代码行数:28,代码来源:response.cpp

示例6: readPointerAtPositionWriteRead

void tst_QRingBuffer::readPointerAtPositionWriteRead()
{
    //create some data
    QBuffer inData;
    inData.open(QIODevice::ReadWrite);
    inData.putChar(0x42);
    inData.putChar(0x23);
    inData.write("Qt rocks!");
    for (int i = 0; i < 5000; i++)
        inData.write(QString("Number %1").arg(i).toUtf8());
    inData.reset();
    QVERIFY(inData.size() > 0);

    //put the inData in the QRingBuffer
    QRingBuffer ringBuffer;
    qint64 remaining = inData.size();
    while (remaining > 0) {
        // write in chunks of 50 bytes
        // this ensures there will be multiple QByteArrays inside the QRingBuffer
        // since QRingBuffer is then only using individual arrays of around 4000 bytes
        qint64 thisWrite = qMin(remaining, qint64(50));
        char *pos = ringBuffer.reserve(thisWrite);
        inData.read(pos, thisWrite);
        remaining -= thisWrite;
    }
    // was data put into it?
    QVERIFY(ringBuffer.size() > 0);
    QCOMPARE(qint64(ringBuffer.size()), inData.size());

    //read from the QRingBuffer in loop, put back into another QBuffer
    QBuffer outData;
    outData.open(QIODevice::ReadWrite);
    remaining = ringBuffer.size();
    while (remaining > 0) {
        qint64 thisRead;
        // always try to read as much as possible
        const char *buf = ringBuffer.readPointerAtPosition(ringBuffer.size() - remaining, thisRead);
        outData.write(buf, thisRead);
        remaining -= thisRead;
    }
    outData.reset();

    QVERIFY(outData.size() > 0);

    // was the data read from the QRingBuffer the same as the one written into it?
    QCOMPARE(outData.size(), inData.size());
    QVERIFY(outData.buffer().startsWith(inData.buffer()));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:48,代码来源:tst_qringbuffer.cpp

示例7: displayFiche

void CustomerInfoPanel::displayFiche(const QString & fichecontent, bool qtui, const QString & id)
{
    Popup * popup = NULL;
    for(int i = m_popups.size() - 1; i >= 0; i --) {
        if(id == m_popups[i]->id()) {
            qDebug() << Q_FUNC_INFO << "fiche id already there" << i << id;
            popup = m_popups[i];
            break;
        }
    }

    QBuffer * inputstream = new QBuffer(this);
    inputstream->open(QIODevice::ReadWrite);
    inputstream->write(fichecontent.toUtf8());
    inputstream->close();

    // Get Data and Popup the profile if ok
    if (popup == NULL) {
        popup = new Popup(m_autourl_allowed);
        m_popups.append(popup);
        popup->setId(id);
        connect(popup, SIGNAL(destroyed(QObject *)),
                this, SLOT(popupDestroyed(QObject *)));
        connect(popup, SIGNAL(wantsToBeShown(Popup *)),
                this, SLOT(showNewProfile(Popup *)));
        connect(popup, SIGNAL(actionFromPopup(const QString &, const QVariant &)),
                this, SLOT(actionFromPopup(const QString &, const QVariant &)));
        connect(popup, SIGNAL(newRemarkSubmitted(const QString &, const QString &)),
                b_engine, SLOT(sendNewRemark(const QString &, const QString &)));
    }
开发者ID:pcadottemichaud,项目名称:xivo-client-qt,代码行数:30,代码来源:customerinfopanel.cpp

示例8:

 void sendDataToDev2(const QByteArray& data) {
     qint64 pos = mDevice2.pos();
     mDevice2.write(data);
     mDevice2.seek(pos);
     // Return to qt event loop to allow it process asincronious signals
     QTest::qWait(1);
 }
开发者ID:lazyphantom,项目名称:qremotesignal,代码行数:7,代码来源:devicemanagertests.cpp

示例9: GenerateCommonHeader

bool QDataProtocol::GenerateCommonHeader( QBuffer& buffer )
{
    qint32 nUInt32Len = sizeof ( quint32 );
    bool bRet = true;

    quint32 nIntValue = H2N< quint32 >( dataPackage.header.common.nDataLength );
    buffer.write( ( const char* ) & nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.common.nReserved );
    buffer.write( ( const char* ) & nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.common.eParcelType );
    buffer.write( ( const char* ) & nIntValue, nUInt32Len );

    return bRet;
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:16,代码来源:qdataprotocol.cpp

示例10: parse

QVariant QJson::parse(const QByteArray& jsonString, bool* ok) {
  QBuffer buffer;
  buffer.open(QBuffer::ReadWrite);
  buffer.write(jsonString);
  buffer.seek(0);
  return parse (&buffer, ok);
}
开发者ID:Open-Turing-Project,项目名称:turing-editor-qt,代码行数:7,代码来源:qjson.cpp

示例11: qWarning

const QByteArray& QxtMailAttachment::rawData() const
{
    if (qxt_d->content == 0)
    {
        qWarning("QxtMailAttachment::rawData(): Content not set!");
        static QByteArray defaultRv;
        return defaultRv;
    }
    if (qobject_cast<QBuffer *>(qxt_d->content.data()) == 0)
    {
        // content isn't hold in a buffer but in another kind of QIODevice
        // (probably a QFile...). Read the data and cache it into a buffer
        static QByteArray empty;
        QIODevice* c = content();
        if (!c->isOpen() && !c->open(QIODevice::ReadOnly))
        {
            qWarning() << "QxtMailAttachment::rawData(): Cannot open content for reading";
            return empty;
        }
        QBuffer* cache = new QBuffer();
        cache->open(QIODevice::WriteOnly);
        char buf[1024];
        while (!c->atEnd())
        {
            cache->write(buf, c->read(buf, 1024));
        }
        if (qxt_d->deleteContent && qxt_d->content)
        qxt_d->content->deleteLater();
        qxt_d->content = cache;
        qxt_d->deleteContent = true;
    }
    return qobject_cast<QBuffer *>(qxt_d->content.data())->data();
}
开发者ID:Ri0n,项目名称:QtMail,代码行数:33,代码来源:mailattachment.cpp

示例12: scanTokens

void TestScanner::scanTokens() {
  QFETCH(QByteArray, input);
  QFETCH(bool, allowSpecialNumbers);
  QFETCH(bool, skipFirstToken);
  QFETCH(int, expectedResult);
  QFETCH(QVariant, expectedYylval);
  QFETCH(int, expectedLocationBeginLine);
  QFETCH(int, expectedLocationBeginColumn);
  QFETCH(int, expectedLocationEndLine);
  QFETCH(int, expectedLocationEndColumn);

  QBuffer buffer;
  buffer.open(QBuffer::ReadWrite);
  buffer.write(input);
  buffer.seek(0);
  JSonScanner scanner(&buffer);
  scanner.allowSpecialNumbers(allowSpecialNumbers);

  QVariant yylval;
  yy::position position(YY_NULL, 1, 0);
  yy::location location(position, position);
  int result = scanner.yylex(&yylval, &location);

  if (skipFirstToken) {
    result = scanner.yylex(&yylval, &location);
  }

  QCOMPARE(result, expectedResult);
  QCOMPARE(yylval, expectedYylval);
  QCOMPARE(location.begin.line, (uint)expectedLocationBeginLine);
  QCOMPARE(location.begin.column, (uint)expectedLocationBeginColumn);
  QCOMPARE(location.end.line, (uint)expectedLocationEndLine);
  QCOMPARE(location.end.column, (uint)expectedLocationEndColumn);
}
开发者ID:OpenModelica,项目名称:OMEdit,代码行数:34,代码来源:testscanner.cpp

示例13: flacStreamEncoderMetadataCallback

void flacStreamEncoderMetadataCallback( const FLAC__StreamEncoder *,
					const FLAC__StreamMetadata * _metadata,
					void * _client_data )
{
	QBuffer * b = static_cast<QBuffer *>( _client_data );
	b->seek( 0 );
	b->write( (const char *) _metadata, sizeof( *_metadata ) );
}
开发者ID:floft,项目名称:lmms,代码行数:8,代码来源:SampleBuffer.cpp

示例14: GenerateTableHeader

bool QDataProtocol::GenerateTableHeader( QBuffer& buffer )
{
    bool bRet = true;
    qint32 nUInt32Len = sizeof ( quint32 );
    qint32 nUInt16Len = sizeof ( quint16 );

    quint32 nIntValue = H2N< quint32 >( dataPackage.header.aux.headerTable.eType );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerTable.nColumnCount );
    buffer.write( ( const char* ) &nIntValue, nUInt16Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerTable.nReserved );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerTable.nRowCount );
    buffer.write( ( const char* ) &nIntValue, nUInt16Len );

    return bRet;
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:20,代码来源:qdataprotocol.cpp

示例15: GenerateFileHeader

bool QDataProtocol::GenerateFileHeader( QBuffer& buffer )
{
    bool bRet = true;
    qint32 nUInt32Len = sizeof ( quint32 );

    quint32 nIntValue = H2N< quint32 >( dataPackage.header.aux.headerFile.eType );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerFile.nContentLength );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerFile.nNameLength );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );

    nIntValue = H2N< quint32 >( dataPackage.header.aux.headerFile.nReserved );
    buffer.write( ( const char* ) &nIntValue, nUInt32Len );


    return bRet;
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:20,代码来源:qdataprotocol.cpp


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