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


C++ QByteArray::insert方法代码示例

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


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

示例1: callTargetRemote

void GdbRemoteServerEngine::callTargetRemote()
{
    QByteArray rawChannel = runParameters().remoteChannel.toLatin1();
    QByteArray channel = rawChannel;

    // Don't touch channels with explicitly set protocols.
    if (!channel.startsWith("tcp:") && !channel.startsWith("udp:")
            && !channel.startsWith("file:") && channel.contains(':')
            && !channel.startsWith('|'))
    {
        // "Fix" the IPv6 case with host names without '['...']'
        if (!channel.startsWith('[') && channel.count(':') >= 2) {
            channel.insert(0, '[');
            channel.insert(channel.lastIndexOf(':'), ']');
        }
        channel = "tcp:" + channel;
    }

    if (m_isQnxGdb)
        postCommand("target qnx " + channel, NoFlags, CB(handleTargetQnx));
    else if (runParameters().multiProcess)
        postCommand("target extended-remote " + channel, NoFlags, CB(handleTargetExtendedRemote));
    else
        postCommand("target remote " + channel, NoFlags, CB(handleTargetRemote));
}
开发者ID:aheubusch,项目名称:qt-creator,代码行数:25,代码来源:remotegdbserveradapter.cpp

示例2: callTargetRemote

void GdbRemoteServerEngine::callTargetRemote()
{
    //m_breakHandler->clearBreakMarkers();

    // "target remote" does three things:
    //     (1) connects to the gdb server
    //     (2) starts the remote application
    //     (3) stops the remote application (early, e.g. in the dynamic linker)
    QByteArray channel = startParameters().remoteChannel.toLatin1();

    // Don't touch channels with explicitly set protocols.
    if (!channel.startsWith("tcp:") && !channel.startsWith("udp:")
            && !channel.startsWith("file:") && channel.contains(':'))
    {
        // "Fix" the IPv6 case with host names without '['...']'
        if (!channel.startsWith('[') && channel.count(':') >= 2) {
            channel.insert(0, '[');
            channel.insert(channel.lastIndexOf(':'), ']');
        }
        channel = "tcp:" + channel;
    }

    if (m_isQnxGdb)
        postCommand("target qnx " + channel, CB(handleTargetQnx));
    else
        postCommand("target remote " + channel, CB(handleTargetRemote));
}
开发者ID:mornelon,项目名称:QtCreator_compliments,代码行数:27,代码来源:remotegdbserveradapter.cpp

示例3: if

// convert MAC from hex string to binary
// e.g. 00:11:22:dd:ee:ff -> 6-byte array
QByteArray SettingDbus::macHex2Bin(const QByteArray &hexMac)
{
    const int MAC_STR_LEN = 17;
    QByteArray ba = hexMac;

    if (ba.isEmpty()) {
        return ba;
    }

    // Check the MAC first and correct it.
    // Although fromHex() ignores invalid characters, it scans the array from
    // the end; so add missing zeroes to have even number of characters.
    for (int i = 0; i < MAC_STR_LEN; i++) {
        char ch = i < ba.size() ? ba.at(i) : ':';
        int mod = i%3;
        if (mod != 2) {
            if (ch == ':') ba.insert(i-mod, "0");
            else if (!isxdigit(ch)) ba[i] = '0';
        } else {
            if (ch != ':') ba.insert(i, ":");
        }
    }
    ba.resize(MAC_STR_LEN);

    return QByteArray::fromHex(ba);
}
开发者ID:RoboMod,项目名称:network-manager-ipop,代码行数:28,代码来源:settingdbus.cpp

示例4: CreateFrame

QByteArray WebSocketWorker::CreateFrame(WebSocketFrame::OpCode type,
                                        const QByteArray &payload)
{
    QByteArray frame;

    int payloadSize = payload.length();

    if (payloadSize >= qPow(2,64))
    {
        LOG(VB_GENERAL, LOG_ERR, "WebSocketWorker::CreateFrame() - Payload "
                              "exceeds the allowed size for a single frame");
        return frame;
    }

    if (type >= 0x08)
    {
        //if (!finalFrame)
        //   SendClose(kCloseProtocolError, "Control frames MUST NOT be fragmented");
        if (payloadSize > 125)
        {
            LOG(VB_GENERAL, LOG_ERR, "WebSocketWorker::CreateFrame() - Control frames MUST NOT have payload greater than 125bytes");
            return frame;
        }
    }

    uint16_t header = 0;
    uint16_t extendedHeader = 0; // For payloads > 125 bytes
    uint64_t superHeader = 0; // For payloads > 65,535 bytes

    // Only support single frames for now
    header |= (1 << 15); // FIN (1 bit)
    // RSV 1 to RSV 3 (1 bit each)
    header |= (type << 8); // OpCode (4 bits)
    header |= (0 << 7); // Mask (1 bit) (Off)
    if (payloadSize < 126)
    {
        header |= payloadSize;
        frame.insert(2, payload.constData(), payloadSize);
    }
    else if (payloadSize <= 65535)
    {
        header |= 126;
        extendedHeader = payloadSize;
        frame.insert(4, payload.constData(), payloadSize);
    }
    else
    {
        header |= 127;
        superHeader = payloadSize;
        frame.insert(10, payload.constData(), payloadSize);
    }

    frame[0] = (uint8_t)((header >> 8) & 0xFF);
    frame[1] = (uint8_t)(header & 0xFF);
    if (extendedHeader > 0)
    {
        frame[2] = (extendedHeader >> 8) & 0xFF;
        frame[3] = extendedHeader & 0xFF;
    }
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:59,代码来源:websocket.cpp

示例5: addAssign

void UmlClass::addAssign(bool cte)
{
    TRACE_FUNCTION;
    UmlOperation * op = UmlOperation::create(this, "operator=");

    if (op == 0)
        UmlCom::trace("can't add assignment contructor");
    else {
        // add 'source' parameter

        UmlParameter param;

        param.name = "source";
        param.dir = (cte) ? InputDirection : InputOutputDirection;
        param.type.type = this;

        op->addParameter(0, param);

        // set return type, add the parameter profile

        UmlTypeSpec t;

        t.type = this;

        op->set_ReturnType(t);

        QByteArray p = (cte) ? "const ${t0} & ${p0}" : "${t0} & ${p0}";
        QByteArray s;
        int index;

        s = op->cppDecl();

        if (s.isEmpty())
            s = CppSettings::operationDecl();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type}")) != -1)
            s.insert(index + 7, " &");

        op->set_CppDecl(s);

        s = op->cppDef();

        if (s.isEmpty())
            s = CppSettings::operationDef();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type}")) != -1)
            s.insert(index + 7, " &");

        op->set_CppDef(s);
    }
}
开发者ID:gilbertoca,项目名称:douml,代码行数:57,代码来源:UmlClass.cpp

示例6: addCopy

void UmlClass::addCopy(bool cte)
{
    TRACE_FUNCTION;
    UmlOperation * op = UmlOperation::create(this, name());

    if (op == 0)
        UmlCom::trace("can't add copy contructor");
    else {
        // to see that it is a copy constructor
        op->set_Stereotype("copy");

        // add 'source' parameter

        UmlParameter param;

        param.name = "source";
        param.dir = (cte) ? InputDirection : InputOutputDirection;
        param.type.type = this;

        op->addParameter(0, param);

        // add the parameter profile, and
        // remove the useless "${type} " mainly to remove the space

        QByteArray p = (cte) ? "const ${t0} & ${p0}" : "${t0} & ${p0}";
        QByteArray s;
        int index;

        s = op->cppDecl();

        if (s.isEmpty())
            s = CppSettings::operationDecl();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);

        op->set_CppDecl(s);

        s = op->cppDef();

        if (s.isEmpty())
            s = CppSettings::operationDef();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);

        op->set_CppDef(s);
    }
}
开发者ID:gilbertoca,项目名称:douml,代码行数:55,代码来源:UmlClass.cpp

示例7: forceIndentWithExtraText

// Add extra text in case of the empty line or the line starting with ')'.
// Track such extra pieces of text in isInsideModifiedLine().
int forceIndentWithExtraText(QByteArray &buffer, const QTextBlock &block, bool secondTry)
{
    const QString blockText = block.text();
    int firstNonWhitespace = Utils::indexOf(blockText,
                                            [](const QChar &ch) { return !ch.isSpace(); });
    int utf8Offset = Utils::Text::utf8NthLineOffset(block.document(),
                                                    buffer,
                                                    block.blockNumber() + 1);
    if (firstNonWhitespace > 0)
        utf8Offset += firstNonWhitespace;
    else
        utf8Offset += blockText.length();

    const bool closingParenBlock = firstNonWhitespace >= 0
                                   && blockText.at(firstNonWhitespace) == ')';

    int extraLength = 0;
    if (firstNonWhitespace < 0 || closingParenBlock) {
        //This extra text works for the most cases.
        QByteArray dummyText("a;a;");

        // Search for previous character
        QTextBlock prevBlock = block.previous();
        bool prevBlockIsEmpty = prevBlock.position() > 0 && prevBlock.text().trimmed().isEmpty();
        while (prevBlockIsEmpty) {
            prevBlock = prevBlock.previous();
            prevBlockIsEmpty = prevBlock.position() > 0 && prevBlock.text().trimmed().isEmpty();
        }
        if (closingParenBlock || prevBlock.text().endsWith(','))
            dummyText = "&& a";

        buffer.insert(utf8Offset, dummyText);
        extraLength += dummyText.length();
    }

    if (secondTry) {
        int nextLinePos = buffer.indexOf('\n', utf8Offset);
        if (nextLinePos < 0)
            nextLinePos = buffer.size() - 1;

        if (nextLinePos > 0) {
            // If first try was not successful try to put ')' in the end of the line to close possibly
            // unclosed parentheses.
            // TODO: Does it help to add different endings depending on the context?
            buffer.insert(nextLinePos, ')');
            extraLength += 1;
        }
    }

    return extraLength;
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:53,代码来源:clangformatbaseindenter.cpp

示例8: Send

void Output_Thread::Send(QByteArray out_data)//посылка данных
{
    //реализовать добавление 0 после D7 в теле протокола
    quint8 i,j=3;
    //---------------------------------------------------
    while((out_data.indexOf((char)0xD7,j))!=-1)
    {
        i=out_data.indexOf((char)0xD7,j);
        out_data.insert(i+1,(char)0x0);
        j=i+1;
         qDebug() << "D7 DETECTED";
    }
    //---------------------------------------------------

    if(port->isOpen())
    {
        data=out_data;
        qint64 snd=port->write(data.data(),data.size());
        qDebug() << "Write is : " << out_data.size() << " bytes";
        if(snd==data.size())
        {
            emit Send_OK(true);//передан весь буфер
        }
        else
        {
           emit Send_OK(false);//передан не весь буфер
        }
    }
    else
    {
        emit Send_OK(false);//порт был закрыт
    }
    usleep(2000);
}
开发者ID:nowhard,项目名称:FREQ_CUR_CONFIG_QT,代码行数:34,代码来源:output_thread.cpp

示例9: formatOutputDataStream

QByteArray CDataFrame::formatOutputDataStream()
{
    QByteArray  d;

    //***填充数据帧
    int size = _data.size();
    d.insert(0,_DLE_BYTE_);
    d.insert(1,_STX_BYTE_);
    d.insert(2,_command);
    d.insert(3,_data);
    d.insert(3+size,_crc);
    d.insert(4+size,_DLE_BYTE_);
    d.insert(5+size,_ETX_BYTE_);

    return d;
}
开发者ID:jiacheng2012,项目名称:311_tester,代码行数:16,代码来源:cdataframe.cpp

示例10: translateBtKeyEvent

QByteArray BtClient::translateBtKeyEvent(QByteArray base)
{
    char length[1];
    length[0] = (char) base.size();
    base.insert(0, length, 1);
    return base;
}
开发者ID:octaveberry,项目名称:remote-keyboard-client,代码行数:7,代码来源:btclient.cpp

示例11: fingerprintify

QString fingerprintify(const QByteArray &ba) {
  const QByteArray &baHex = ba.toHex();
  QByteArray result = baHex;
  for (int i = baHex.size() - 2; i > 0; i -= 2)
    result.insert(i, ':');
  return result;
}
开发者ID:noudvankruysbergen,项目名称:Qt-SESAM,代码行数:7,代码来源:util.cpp

示例12: saveSoundTrack

void Ffmpeg::saveSoundTrack(TSoundTrack *st) {
  m_sampleRate    = st->getSampleRate();
  m_channelCount  = st->getChannelCount();
  m_bitsPerSample = st->getBitPerSample();
  // LONG count = st->getSampleCount();
  int bufSize         = st->getSampleCount() * st->getSampleSize();
  const UCHAR *buffer = st->getRawData();

  m_audioPath = getFfmpegCache().getQString() + "//" +
                QString::fromStdString(m_path.getName()) + "tempOut.raw";
  m_audioFormat = "s" + QString::number(m_bitsPerSample);
  if (m_bitsPerSample > 8) m_audioFormat = m_audioFormat + "le";
  std::string strPath                    = m_audioPath.toStdString();

  QByteArray data;
  data.insert(0, (char *)buffer, bufSize);

  QFile file(m_audioPath);
  file.open(QIODevice::WriteOnly);
  file.write(data);
  file.close();
  m_hasSoundTrack = true;

  m_audioArgs << "-f";
  m_audioArgs << m_audioFormat;
  m_audioArgs << "-ar";
  m_audioArgs << QString::number(m_sampleRate);
  m_audioArgs << "-ac";
  m_audioArgs << QString::number(m_channelCount);
  m_audioArgs << "-i";
  m_audioArgs << m_audioPath;

  // add file to framesWritten for cleanup
  m_cleanUpList.push_back(m_audioPath);
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:35,代码来源:tiio_ffmpeg.cpp

示例13: connected

void FileSender::connected(void)
{
	QByteArray data = id.toLocal8Bit();
	data.insert(0, "FILE");	// insert indicator that this socket handles file transfer
	//	send an id message and then wait for a START message 
	//	from receiver, which will trigger readyRead signal
	socket->write(data);
}
开发者ID:j2doll,项目名称:lmc-clone,代码行数:8,代码来源:netstreamer.cpp

示例14: sendTestResultToServer

void TcpClient::sendTestResultToServer(const StudentResult &result)
{
    //create msg string
    QString studentResult = result.testName
            + divSymbol
            + result.firstName
            + divSymbol
            + result.secondName
            + divSymbol
            + result.surname
            + divSymbol
            + result.group
            + divSymbol
            + QString::number(result.score)
            + divSymbol
            + QString::number(result.maxPosibleScore);

    for (int i = 0; i < result.answerInfo.count(); i++) {
        studentResult += divSymbol;
        studentResult += result.answerInfo.at(i).statement;
        studentResult += divSymbol;
        studentResult += result.answerInfo.at(i).chosenAnswer;
        studentResult += divSymbol;
        studentResult += QString::number(result.answerInfo.at(i).isCorrectAnswer);
        studentResult += divSymbol;
        studentResult += QString::number(result.answerInfo.at(i).assurance);
    }

    //non latin symbols have more size then latin,
    //so string length != real symbols array size
    QByteArray bytes = studentResult.toUtf8();
    //calculate msg sum
    int msgSize = headerMsgSize + bytes.length();

    //put data to bytearray
    QByteArray  arrBlock;
    arrBlock.fill(0, msgSize);
    arrBlock.insert(0, QString::number(msgSize));
    arrBlock.insert(headerMsgSize, studentResult);
    arrBlock.resize(msgSize);

    //send data to server
    qDebug() << m_pTcpSocket->write(arrBlock);
    m_pTcpSocket->waitForBytesWritten(3000);
}
开发者ID:TatianaBorisova,项目名称:TestApplication,代码行数:45,代码来源:tcpclient.cpp

示例15: main

int main(int argc, char *argv[])
{
    if (argc <= 1)
        qFatal("Usage: %s FILES", argc ? argv[0] : "fixnonlatin1");
    for (int i = 1; i < argc; ++i) {

        QString fileName = QString::fromLocal8Bit(argv[i]);
        if (   fileName.endsWith(".gif")
            || fileName.endsWith(".jpg")
            || fileName.endsWith(".tif")
            || fileName.endsWith(".tiff")
            || fileName.endsWith(".png")
            || fileName.endsWith(".mng")
            || fileName.endsWith(".ico")
            || fileName.endsWith(".zip")
            || fileName.endsWith(".gz")
            || fileName.endsWith(".qpf")
            || fileName.endsWith(".ttf")
            || fileName.endsWith(".pfb")
            || fileName.endsWith(".exe")
            || fileName.endsWith(".nib")
            || fileName.endsWith(".o")
            )
            continue;

        QFile file(fileName);
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            qFatal("Cannot open '%s': %s", argv[i], qPrintable(file.errorString()));

        QByteArray ba = file.readAll();
        bool mod = false;
        for (int j = 0; j < ba.count(); ++j) {
            uchar c = ba.at(j);
            if (c > 127) {
                ba[j] = '\\';
                ba.insert(j + 1, QByteArray::number(c, 8).rightJustified(3, '0', true));
                j += 3;
                mod = true;
            }
        }
        file.close();

        if (!mod)
            continue;

        qWarning("found non-latin1 characters in '%s'", argv[i]);
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
            qWarning("Cannot open '%s' for writing: %s", argv[i], qPrintable(file.errorString()));
            continue;
        }
        if (file.write(ba) < 0)
            qFatal("Error while writing into '%s': %s", argv[i], qPrintable(file.errorString()));
        file.close();
    }

    return 0;
}
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:57,代码来源:main.cpp


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