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


C++ outputString函数代码示例

本文整理汇总了C++中outputString函数的典型用法代码示例。如果您正苦于以下问题:C++ outputString函数的具体用法?C++ outputString怎么用?C++ outputString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Example

    explicit Example( storm::Window::Pointer window ) :
        _window( std::move(window) ),
        _observer( std::make_shared<storm::WindowObserver>() )
    {
        _window->setWindowedMode( outputWindowDimensions );
        _window->addObserver( _observer );

        _observer->onShutdownRequested = [] {
            outputString( "Shutdown requested" );
        };
        _observer->onFocusReceived = [] {
            outputString( "Focus received" );
        };
        _observer->onFocusLost = [] {
            outputString( "Focus lost" );
        };
        _observer->onResized = [this] {
            outputString(
                "The window size is changed. The new size is: " +
                    std::to_string(_window->getDimensions().width) + ", " +
                    std::to_string(_window->getDimensions().height) );
        };
        _observer->onMouseMotion = []( storm::IntVector2d value ) {
            outputString(
                "The mouse is moved. The delta is: " +
                    std::to_string(value.x) + ", " +
                    std::to_string(value.y) );
        };
        _observer->onMouseButtonPressed = []( storm::MouseButton value ) {
            outputString(
                "The mouse button is pressed. The value is: " +
                    std::to_string(static_cast<int>(value)) );
        };
        _observer->onMouseButtonReleased = []( storm::MouseButton value ) {
            outputString(
                "The mouse button is released. The value is: " +
                    std::to_string(static_cast<int>(value)) );
        };
        _observer->onMouseWheelRotated = []( float value ) {
            outputString(
                "The mouse wheel is rotated. The delta is: " +
                    std::to_string(value) );
        };
        _observer->onPointerMotion = []( storm::IntVector2d value ) {
            outputString(
                "The mouse pointer is moved. The position is: " +
                    std::to_string(value.x) + ", " +
                    std::to_string(value.y) );
        };
        _observer->onKeyboardKeyPressed = [this]( storm::KeyboardKey value ) {
            outputString(
                "A keyboard key is pressed. The key is: " +
                    std::string(getKeyboardKeyName(value)) );

            processKeyPress( value );
        };
        _observer->onKeyboardKeyRepeated = []( storm::KeyboardKey value ) {
            outputString(
                "A keyboard key is repeated. The key is: " +
                    std::string(getKeyboardKeyName(value)) );
        };
        _observer->onKeyboardKeyReleased = []( storm::KeyboardKey value ) {
            outputString(
                "A keyboard key is released. The key is: " +
                    std::string(getKeyboardKeyName(value)) );
        };
        _observer->onCharacterInput = []( char32_t character ) {
            std::mbstate_t state = {};
            std::string buffer( MB_CUR_MAX, 0 );
            std::c32rtomb( buffer.data(), character, &state );

            outputString( "Character input: " + buffer +
                " (" + std::to_string(character) + ")" );
        };
    }
开发者ID:vanderlokken,项目名称:storm,代码行数:75,代码来源:user_input.cpp

示例2: outputString

void MiningPage::readProcessOutput()
{
    QByteArray output;

    minerProcess->reset();

    output = minerProcess->readAll();

    QString outputString(output);

    if (!outputString.isEmpty())
    {
        QStringList list = outputString.split("\n", QString::SkipEmptyParts);
        int i;
        for (i=0; i<list.size(); i++)
        {
            QString line = list.at(i);

            // Ignore protocol dump
            if (!line.startsWith("[") || line.contains("JSON protocol") || line.contains("HTTP hdr"))
                continue;

            if (ui->debugCheckBox->isChecked())
            {
                ui->list->addItem(line.trimmed());
                ui->list->scrollToBottom();
            }

            if (line.contains("(yay!!!)"))
                reportToList("Share accepted", SHARE_SUCCESS, getTime(line));
            else if (line.contains("(booooo)"))
                reportToList("Share rejected", SHARE_FAIL, getTime(line));
            else if (line.contains("LONGPOLL detected new block"))
                reportToList("LONGPOLL detected a new block", LONGPOLL, getTime(line));
            else if (line.contains("Supported options:"))
                reportToList("Miner didn't start properly. Try checking your settings.", ERROR, NULL);
            else if (line.contains("The requested URL returned error: 403"))
                reportToList("Couldn't connect. Please check your username and password.", ERROR, NULL);
            else if (line.contains("HTTP request failed"))
                reportToList("Couldn't connect. Please check pool server and port.", ERROR, NULL);
            else if (line.contains("JSON-RPC call failed"))
                reportToList("Couldn't communicate with server. Retrying in 30 seconds.", ERROR, NULL);
            else if (line.contains("thread ") && line.contains("khash/s"))
            {
                QString threadIDstr = line.at(line.indexOf("thread ")+7);
                int threadID = threadIDstr.toInt();

                int threadSpeedindx = line.indexOf(",");
                QString threadSpeedstr = line.mid(threadSpeedindx);
                threadSpeedstr.chop(8);
                threadSpeedstr.remove(", ");
                threadSpeedstr.remove(" ");
                threadSpeedstr.remove('\n');
                double speed=0;
                speed = threadSpeedstr.toDouble();

                threadSpeed[threadID] = speed;

                updateSpeed();
            }
        }
    }
}
开发者ID:CaptChadd,项目名称:Extremecoin,代码行数:63,代码来源:miningpage.cpp

示例3: handleTalk

	void handleTalk(){
		outputString("Baldevarth: Good day, my enthusiastic protege.  What can I do for you?");
	}
开发者ID:krieghan,项目名称:archmage_c,代码行数:3,代码来源:archmageactors.cpp

示例4: outputString

void QTestXunitStreamer::output(QTestElement *element) const
{
    outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
    QTestBasicStreamer::output(element);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:5,代码来源:qtestxunitstreamer.cpp

示例5: setThreadNotRunning


//.........这里部分代码省略.........
		return;
	}
	if(exitCode) *exitCode = -1;
	if(!GD::bl->io.fileExists(path))
	{
		GD::out.printError("Error: PHP script \"" + path + "\" does not exist.");
		setThreadNotRunning(threadId);
		return;
	}
	ts_resource_ex(0, NULL); //Replaces TSRMLS_FETCH()
	try
	{
		zend_file_handle script;

		/* Set up a File Handle structure */
		script.type = ZEND_HANDLE_FILENAME;
		script.filename = path.c_str();
		script.opened_path = NULL;
		script.free_filename = 0;

		zend_homegear_globals* globals = php_homegear_get_globals();
		if(!globals)
		{
			ts_free_thread();
			setThreadNotRunning(threadId);
			return;
		}
		globals->output = output.get();
		globals->commandLine = true;
		globals->cookiesParsed = true;

		if(!tsrm_get_ls_cache() || !((sapi_globals_struct *) (*((void ***) tsrm_get_ls_cache()))[((sapi_globals_id)-1)]) || !((php_core_globals *) (*((void ***) tsrm_get_ls_cache()))[((core_globals_id)-1)]))
		{
			GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists.");
			ts_free_thread();
			setThreadNotRunning(threadId);
			return;
		}
		PG(register_argc_argv) = 1;
		SG(server_context) = (void*)output.get(); //Must be defined! Otherwise php_homegear_activate is not called.
		SG(options) |= SAPI_OPTION_NO_CHDIR;
		SG(headers_sent) = 1;
		SG(request_info).no_headers = 1;
		SG(default_mimetype) = nullptr;
		SG(default_charset) = nullptr;
		SG(request_info).path_translated = estrndup(path.c_str(), path.size());

		if (php_request_startup(TSRMLS_C) == FAILURE) {
			GD::bl->out.printError("Error calling php_request_startup...");
			ts_free_thread();
			setThreadNotRunning(threadId);
			return;
		}

		std::vector<std::string> argv = getArgs(path, arguments);
		php_homegear_build_argv(argv);
		SG(request_info).argc = argv.size();
		SG(request_info).argv = (char**)malloc((argv.size() + 1) * sizeof(char*));
		for(uint32_t i = 0; i < argv.size(); ++i)
		{
			SG(request_info).argv[i] = (char*)argv[i].c_str(); //Value is not modified.
		}
		SG(request_info).argv[argv.size()] = nullptr;

		php_execute_script(&script);
		if(exitCode) *exitCode = EG(exit_status);

		php_request_shutdown(NULL);
		if(output->size() > 0)
		{
			std::string outputString(&output->at(0), output->size());
			if(BaseLib::HelperFunctions::trim(outputString).size() > 0) GD::out.printMessage("Script output:\n" + outputString);
		}
	}
	catch(const std::exception& ex)
	{
		GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
	}
	catch(BaseLib::Exception& ex)
	{
		GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
	}
	catch(...)
	{
		GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
	}
	if(SG(request_info).path_translated)
	{
		efree(SG(request_info).query_string);
		SG(request_info).query_string = nullptr;
	}
	if(SG(request_info).argv)
	{
		free(SG(request_info).argv);
		SG(request_info).argv = nullptr;
	}
	SG(request_info).argc = 0;
	ts_free_thread();
	setThreadNotRunning(threadId);
}
开发者ID:pauxus,项目名称:Homegear,代码行数:101,代码来源:ScriptEngine.cpp

示例6: handleLook

	void handleLook(){
		outputString("Look there, it's you!");
	}
开发者ID:krieghan,项目名称:archmage_c,代码行数:3,代码来源:archmageactors.cpp

示例7: outputNum

void outputNum(double num, double x, double y, bool window)
{
	std::string word = to_string(num);
	outputString(word, x, y, window);
}
开发者ID:EthanRutherford,项目名称:geneticcars,代码行数:5,代码来源:main.cpp

示例8: outputString

void QXmlTestLogger::leaveTestFunction()
{
    outputString("</TestFunction>\n");
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:4,代码来源:qxmltestlogger.cpp

示例9: sizeof

void QXmlTestLogger::enterTestFunction(const char *function)
{
    char buf[1024];
    QTest::qt_snprintf(buf, sizeof(buf), "<TestFunction name=\"%s\">\n", function);
    outputString(buf);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:6,代码来源:qxmltestlogger.cpp

示例10: printf


//.........这里部分代码省略.........
      rv = tmpDownloadFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
      NS_ENSURE_SUCCESS(rv, rv);

      m_tmpDownloadFile = do_QueryInterface(tmpDownloadFile, &rv);
    }
    if (NS_SUCCEEDED(rv))
    {
      rv = MsgGetFileStream(m_tmpDownloadFile, getter_AddRefs(m_outFileStream));
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }
  else
  {
    rv = server->GetMsgStore(getter_AddRefs(m_msgStore));
    bool reusable;
    NS_ENSURE_SUCCESS(rv, rv);
    m_msgStore->GetNewMsgOutputStream(m_folder, getter_AddRefs(newHdr),
                                      &reusable, getter_AddRefs(m_outFileStream));
  }
  // The following (!m_outFileStream etc) was added to make sure that we don't
  // write somewhere where for some reason or another we can't write to and
  // lose the messages. See bug 62480
  if (!m_outFileStream)
      return NS_ERROR_OUT_OF_MEMORY;

  nsCOMPtr<nsISeekableStream> seekableOutStream = do_QueryInterface(m_outFileStream);

  // create a new mail parser
  if (!m_newMailParser)
    m_newMailParser = new nsParseNewMailState;
  NS_ENSURE_TRUE(m_newMailParser, NS_ERROR_OUT_OF_MEMORY);
  if (m_uidlDownload)
    m_newMailParser->DisableFilters();

  nsCOMPtr <nsIMsgFolder> serverFolder;
  rv = GetServerFolder(getter_AddRefs(serverFolder));
  if (NS_FAILED(rv)) return rv;

  rv = m_newMailParser->Init(serverFolder, m_folder,
                             m_window, newHdr, m_outFileStream);
  // If we failed to initialize the parser, then just don't use it!!!
  // We can still continue without one.

  if (NS_FAILED(rv))
  {
    m_newMailParser = nullptr;
    rv = NS_OK;
  }
  else
  {
    if (m_downloadingToTempFile)
    {
      // Tell the parser to use the offset that will be in the dest folder,
      // not the temp folder, so that the msg hdr will start off with
      // the correct mdb oid
      int64_t fileSize;
      path->GetFileSize(&fileSize);
      m_newMailParser->SetEnvelopePos((uint32_t) fileSize);
    }
  }
    if (closure)
        *closure = (void*) this;

    nsCString outputString(GetDummyEnvelope());
    rv = WriteLineToMailbox(outputString);
    NS_ENSURE_SUCCESS(rv, rv);
    // Write out account-key before UIDL so the code that looks for
    // UIDL will find the account first and know it can stop looking
    // once it finds the UIDL line.
    if (!m_accountKey.IsEmpty())
    {
      outputString.AssignLiteral(HEADER_X_MOZILLA_ACCOUNT_KEY ": ");
      outputString.Append(m_accountKey);
      outputString.AppendLiteral(MSG_LINEBREAK);
      rv = WriteLineToMailbox(outputString);
      NS_ENSURE_SUCCESS(rv, rv);
    }
    if (uidlString)
    {
      outputString.AssignLiteral("X-UIDL: ");
      outputString.Append(uidlString);
      outputString.AppendLiteral(MSG_LINEBREAK);
      rv = WriteLineToMailbox(outputString);
      NS_ENSURE_SUCCESS(rv, rv);
    }

    // WriteLineToMailbox("X-Mozilla-Status: 8000" MSG_LINEBREAK);
    char *statusLine = PR_smprintf(X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, flags);
    outputString.Assign(statusLine);
    rv = WriteLineToMailbox(outputString);
    PR_smprintf_free(statusLine);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = WriteLineToMailbox(NS_LITERAL_CSTRING("X-Mozilla-Status2: 00000000" MSG_LINEBREAK));
    NS_ENSURE_SUCCESS(rv, rv);

    // leave space for 60 bytes worth of keys/tags
    rv = WriteLineToMailbox(NS_LITERAL_CSTRING(X_MOZILLA_KEYWORDS));
    return NS_OK;
}
开发者ID:html-shell,项目名称:releases-comm-central,代码行数:101,代码来源:nsPop3Sink.cpp

示例11: initStyleOption

void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItemV4 opt = option;
    initStyleOption(&opt, index);
    // make sure we paint the complete delegate instead of keeping an offset
    opt.rect.adjust(-opt.rect.x(), 0, 0, 0);
    painter->save();

    QFontMetrics fm(opt.font);
    QColor foreground;

    const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(opt.widget);
    const bool selected = view->selectionModel()->currentIndex() == index;

    if (selected) {
        painter->setBrush(opt.palette.highlight().color());
        foreground = opt.palette.highlightedText().color();
    } else {
        painter->setBrush(opt.palette.background().color());
        foreground = opt.palette.text().color();
    }
    painter->setPen(Qt::NoPen);
    painter->drawRect(opt.rect);
    painter->setPen(foreground);

    TestResultFilterModel *resultFilterModel = static_cast<TestResultFilterModel *>(view->model());
    LayoutPositions positions(opt, resultFilterModel);
    const TestResult &testResult = resultFilterModel->testResult(index);

    // draw the indicator by ourself as we paint across it with the delegate
    QStyleOptionViewItemV4 indicatorOpt = option;
    indicatorOpt.rect = QRect(0, opt.rect.y(), positions.indentation(), opt.rect.height());
    opt.widget->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &indicatorOpt, painter);

    QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
    if (!icon.isNull())
        painter->drawPixmap(positions.left(), positions.top(),
                            icon.pixmap(positions.iconSize(), positions.iconSize()));

    QString typeStr = TestResult::resultToString(testResult.result());
    if (selected) {
        painter->drawText(positions.typeAreaLeft(), positions.top() + fm.ascent(), typeStr);
    } else {
        QPen tmp = painter->pen();
        painter->setPen(TestResult::colorForType(testResult.result()));
        painter->drawText(positions.typeAreaLeft(), positions.top() + fm.ascent(), typeStr);
        painter->setPen(tmp);
    }

    QString output = outputString(testResult, selected);

    if (selected) {
        output.replace(QLatin1Char('\n'), QChar::LineSeparator);

        if (AutotestPlugin::instance()->settings()->limitResultOutput
                && output.length() > outputLimit)
            output = output.left(outputLimit).append(QLatin1String("..."));

        recalculateTextLayout(index, output, painter->font(), positions.textAreaWidth());

        m_lastCalculatedLayout.draw(painter, QPoint(positions.textAreaLeft(), positions.top()));
    } else {
        painter->setClipRect(positions.textArea());
        // cut output before generating elided text as this takes quite long for exhaustive output
        painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(),
                          fm.elidedText(output.left(2000), Qt::ElideRight, positions.textAreaWidth()));
    }

    QString file = testResult.fileName();
    const int pos = file.lastIndexOf(QLatin1Char('/'));
    if (pos != -1)
        file = file.mid(pos + 1);

    painter->setClipRect(positions.fileArea());
    painter->drawText(positions.fileAreaLeft(), positions.top() + fm.ascent(), file);


    if (testResult.line()) {
        QString line = QString::number(testResult.line());
        painter->setClipRect(positions.lineArea());
        painter->drawText(positions.lineAreaLeft(), positions.top() + fm.ascent(), line);
    }

    painter->setClipRect(opt.rect);
    painter->setPen(opt.palette.midlight().color());
    painter->drawLine(0, opt.rect.bottom(), opt.rect.right(), opt.rect.bottom());
    painter->restore();
}
开发者ID:acacid,项目名称:qt-creator,代码行数:88,代码来源:testresultdelegate.cpp


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