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


C++ QProcess::getChar方法代码示例

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


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

示例1: getChar

bool QProcessProto::getChar(char *c)
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    return item->getChar(c);
  return false;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: tryToReadStdOutChar

bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
{
    char readChar = '\0';
    if (!process.getChar(&readChar))
        return false;

    if (!mCapabilities.progressReporting())
        return true; // We did read something but it's not in a format we can parse.

    if (readChar == ':')
    {
        mLastRuleID = mReadBuffer;
        if (mReadingRuleID) // sanity check
        {
            emit progressReport(mLastRuleID, "processing");
        }
        else
        {
            emit warningMessage(QString(
                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                "':' encountered while not reading rule ID, newline and/or rule result are missing! "
                "Read buffer is '%1'.")).arg(mReadBuffer));
        }
        mReadBuffer = "";
        mReadingRuleID = false;
    }
    else if (readChar == '\n')
    {
        if (!mReadingRuleID) // sanity check
        {
            emit progressReport(mLastRuleID, mReadBuffer);
        }
        else
        {
            emit warningMessage(QString(
                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                "Newline encountered while reading rule ID, rule result and/or ':' are missing! "
                "Read buffer is '%1'.")).arg(mReadBuffer));
        }
        mReadBuffer = "";
        mReadingRuleID = true;
    }
    else
    {
        // we know for sure that buffer[0] can only contain ASCII characters
        // (IDs and special keywords regarding rule status)
        mReadBuffer.append(QChar::fromAscii(readChar));
    }

    return true;
}
开发者ID:finkr,项目名称:scap-workbench,代码行数:51,代码来源:OscapScannerBase.cpp

示例3: readLine

bool readLine(QProcess& client) {
  unsigned int i = 0;
  char c;
  if(!client.getChar(&c)) {
    client.waitForReadyRead();
  }
  else {
    buffer[i++] = c;
  }
  
  while(client.getChar(&c) && c != '\n') {
    buffer[i++] = c;
  }
  buffer[i] = '\0';
  
  if(c == '\n') {
    return true;
  }
  else {
    client.kill();
    client.waitForFinished();
    return false;
  }
}
开发者ID:astralien3000,项目名称:aversive--,代码行数:24,代码来源:util.cpp

示例4: tryToReadStdOutChar

bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
{
    char readChar = '\0';
    if (!process.getChar(&readChar))
        return false;

    if (!mCapabilities.progressReporting())
        return true; // We did read something but it's not in a format we can parse.

    if (readChar == ':')
    {
        switch (mReadingState)
        {
            case RS_READING_PREFIX:
                {
                    // Openscap <= 1.2.10 (60fb9f0c98eee) sends this message through stdout
                    if (mReadBuffer=="Downloading")
                    {
                         mReadingState = RS_READING_DOWNLOAD_FILE;
                    }
                    else
                    {
                        mLastRuleID = mReadBuffer;
                        emit progressReport(mLastRuleID, "processing");
                        mReadingState = RS_READING_RULE_RESULT;
                    }
                    mReadBuffer = "";
                }
                break;

            case RS_READING_RULE_RESULT:
                {
                    emit warningMessage(QString(
                                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                                    "':' encountered while not reading rule ID, newline and/or rule result are missing! "
                                    "Read buffer is '%1'.")).arg(mReadBuffer));
                    mReadBuffer = "";
                }
                break;
            case RS_READING_DOWNLOAD_FILE:
                {
                    // When fetching remote content, openscap will inform scap-workbench about
                    // resources being downloaded. Keep any colon found in URL of file being downloaded.
                    mReadBuffer.append(QChar::fromAscii(readChar));
                }
                break;

            default:
                // noop
                break;
        }
    }
    else if (readChar == '\n')
    {
        switch(mReadingState)
        {
            case RS_READING_PREFIX:
                // If we found a '\n' while reading prefix, we might have received an error or
                // warning message through stdout.
                if (mReadBuffer.contains("--fetch-remote-resources"))
                {
                    // If message is about --fetch-remote-resources, emit a nice warning.
                    // This is needed for workbench to be able to handle messages from machines
                    // running older versions of openscap.
                    // From openscap version 1.2.11, this message is sent through stderr
                    // and therefore is handled accordingly by workbench.
                    emit warningMessage(guiFriendlyMessage(mReadBuffer));
                }
                else
                {
                    // No other error or warning messages are expected through stdout,
                    // so it is likely that a parsing error occured.
                    emit warningMessage(QString(
                                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                                    "Newline encountered while reading rule ID, rule result and/or ':' are missing! "
                                    "Read buffer is '%1'.")).arg(mReadBuffer));
                }
                break;

            case RS_READING_RULE_RESULT:
                emit progressReport(mLastRuleID, mReadBuffer);
                break;

            case RS_READING_DOWNLOAD_FILE_STATUS:
                {
                    QString downloadStatus = mReadBuffer.mid(1);
                    if (downloadStatus == "ok")
                        emit infoMessage(QString("Downloading of \"%1\" finished: %2").arg(mLastDownloadingFile).arg(downloadStatus));
                    else
                        emit warningMessage(QString("Failed to download \"%1\"!").arg(mLastDownloadingFile));
                }
                break;
            default:
                // noop
                break;
        }
        mReadingState = RS_READING_PREFIX;
        mReadBuffer = "";
    }
    else if ( (readChar == '.') && (mReadingState == RS_READING_DOWNLOAD_FILE) && (mReadBuffer.endsWith(" ..")))
//.........这里部分代码省略.........
开发者ID:OpenSCAP,项目名称:scap-workbench,代码行数:101,代码来源:OscapScannerBase.cpp


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