本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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(" ..")))
//.........这里部分代码省略.........