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


C++ ErrorMessage::toString方法代码示例

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


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

示例1: TestPatternSearchReplace

    void TestPatternSearchReplace(const std::string& idPlaceholder, const std::string& id) const {
        const std::string plainText = "text";

        ErrorLogger::ErrorMessage message;
        message._id = id;

        std::string serialized = message.toString(true, idPlaceholder + plainText + idPlaceholder);
        ASSERT_EQUALS(id + plainText + id, serialized);

        serialized = message.toString(true, idPlaceholder + idPlaceholder);
        ASSERT_EQUALS(id + id, serialized);

        serialized = message.toString(true, plainText + idPlaceholder + plainText);
        ASSERT_EQUALS(plainText + id + plainText, serialized);
    }
开发者ID:matthiaskrgr,项目名称:cppcheck,代码行数:15,代码来源:testerrorlogger.cpp

示例2: reportErr

void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    if (!_settings.library.reportErrors(msg.file0))
        return;

    const std::string errmsg = msg.toString(_settings.verbose);
    if (errmsg.empty())
        return;

    // Alert only about unique errors
    if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
        return;

    std::string file;
    unsigned int line(0);
    if (!msg._callStack.empty()) {
        file = msg._callStack.back().getfile(false);
        line = msg._callStack.back().line;
    }

    if (_useGlobalSuppressions) {
        if (_settings.nomsg.isSuppressed(msg._id, file, line))
            return;
    } else {
        if (_settings.nomsg.isSuppressedLocal(msg._id, file, line))
            return;
    }

    if (!_settings.nofail.isSuppressed(msg._id, file, line))
        exitcode = 1;

    _errorList.push_back(errmsg);

    _errorLogger.reportErr(msg);
}
开发者ID:HeisSpiter,项目名称:cppcheck,代码行数:35,代码来源:cppcheck.cpp

示例3: handleRead

int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
{
    char type = 0;
    if (read(rpipe, &type, 1) <= 0) {
        if (errno == EAGAIN)
            return 0;

        return -1;
    }

    if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    unsigned int len = 0;
    if (read(rpipe, &len, sizeof(len)) <= 0) {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    char *buf = new char[len];
    if (read(rpipe, buf, len) <= 0) {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    if (type == REPORT_OUT) {
        _errorLogger.reportOut(buf);
    } else if (type == REPORT_ERROR || type == REPORT_INFO) {
        ErrorLogger::ErrorMessage msg;
        msg.deserialize(buf);

        std::string file;
        unsigned int line(0);
        if (!msg._callStack.empty()) {
            file = msg._callStack.back().getfile(false);
            line = msg._callStack.back().line;
        }

        if (!_settings.nomsg.isSuppressed(msg._id, file, line)) {
            // Alert only about unique errors
            std::string errmsg = msg.toString(_settings._verbose);
            if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {
                _errorList.push_back(errmsg);
                if (type == REPORT_ERROR)
                    _errorLogger.reportErr(msg);
                else
                    _errorLogger.reportInfo(msg);
            }
        }
    } else if (type == CHILD_END) {
        std::istringstream iss(buf);
        unsigned int fileResult = 0;
        iss >> fileResult;
        result += fileResult;
        delete [] buf;
        return -1;
    }
开发者ID:kasumar,项目名称:TscanCode,代码行数:59,代码来源:threadexecutor.cpp

示例4: reportErr

void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    if (errorlist) {
        reportOut(msg.toXML(false, _settings->_xml_version));
    } else if (_settings->_xml) {
        reportErr(msg.toXML(_settings->_verbose, _settings->_xml_version));
    } else {
        reportErr(msg.toString(_settings->_verbose, _settings->_outputFormat));
    }
}
开发者ID:bnagesh,项目名称:cppcheck,代码行数:10,代码来源:cppcheckexecutor.cpp

示例5: reportErr

void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    const std::string errmsg = msg.toString(_settings._verbose);
    if (errmsg.empty())
        return;

    if (_settings.debugFalsePositive) {
        // Don't print out error
        _errorList.push_back(errmsg);
        return;
    }

    // Alert only about unique errors
    if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
        return;

    std::string file;
    unsigned int line(0);
    if (!msg._callStack.empty()) {
        file = msg._callStack.back().getfile(false);
        line = msg._callStack.back().line;
    }

    if (_useGlobalSuppressions) {
        if (_settings.nomsg.isSuppressed(msg._id, file, line))
            return;
    } else {
        if (_settings.nomsg.isSuppressedLocal(msg._id, file, line))
            return;
    }

    if (!_settings.nofail.isSuppressed(msg._id, file, line))
        exitcode = 1;

    _errorList.push_back(errmsg);
    std::string errmsg2(errmsg);
    if (_settings._verbose) {
        errmsg2 += "\n    Defines=\'" + cfg + "\'\n";
    }

    _errorLogger.reportErr(msg);

    _errout << errmsg2 << std::endl;
}
开发者ID:Drahakar,项目名称:cppcheck,代码行数:44,代码来源:cppcheck.cpp

示例6: reportErr

void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    mSuppressInternalErrorFound = false;

    if (!mSettings.library.reportErrors(msg.file0))
        return;

    const std::string errmsg = msg.toString(mSettings.verbose);
    if (errmsg.empty())
        return;

    // Alert only about unique errors
    if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) != mErrorList.end())
        return;

    const Suppressions::ErrorMessage errorMessage = msg.toSuppressionsErrorMessage();

    if (mUseGlobalSuppressions) {
        if (mSettings.nomsg.isSuppressed(errorMessage)) {
            mSuppressInternalErrorFound = true;
            return;
        }
    } else {
        if (mSettings.nomsg.isSuppressedLocal(errorMessage)) {
            mSuppressInternalErrorFound = true;
            return;
        }
    }

    if (!mSettings.nofail.isSuppressed(errorMessage) && (mUseGlobalSuppressions || !mSettings.nomsg.isSuppressed(errorMessage)))
        mExitCode = 1;

    mErrorList.push_back(errmsg);

    mErrorLogger.reportErr(msg);
    mAnalyzerInformation.reportErr(msg, mSettings.verbose);
    if (!mSettings.plistOutput.empty() && plistFile.is_open()) {
        plistFile << ErrorLogger::plistData(msg);
    }
}
开发者ID:eranif,项目名称:codelite,代码行数:40,代码来源:cppcheck.cpp

示例7: report

void TscThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType msgType)
{
    std::string file;
    unsigned int line(0);
    if (!msg._callStack.empty()) {
        file = msg._callStack.back().getfile(false);
        line = msg._callStack.back().line;
    }

    if (_settings.nomsg.isSuppressed(msg._id, file, line))
        return;

    // Alert only about unique errors
    bool reportError = false;
    std::string errmsg = msg.toString(_settings._verbose);

    TSC_LOCK_ENTER(&_errorSync);
    if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {
        _errorList.push_back(errmsg);
        reportError = true;
    }
    TSC_LOCK_LEAVE(&_errorSync);

    if (reportError) {
        TSC_LOCK_ENTER(&_reportSync);

        switch (msgType) {
        case REPORT_ERROR:
            _errorLogger.reportErr(msg);
            break;
        case REPORT_INFO:
            _errorLogger.reportInfo(msg);
            break;
        }

        TSC_LOCK_LEAVE(&_reportSync);
    }
}
开发者ID:hxofgithub,项目名称:TscanCode,代码行数:38,代码来源:tscthreadexecutor.cpp

示例8: reportErr

void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    const std::string errormessage(msg.toString(false));
    if (errout.str().find(errormessage) == std::string::npos)
        errout << errormessage << std::endl;
}
开发者ID:NightOfTwelve,项目名称:cppcheck,代码行数:6,代码来源:testsuite.cpp

示例9: reportErr

void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    errout << msg.toString() << std::endl;
}
开发者ID:malife,项目名称:cppcheck,代码行数:4,代码来源:testsuite.cpp


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