本文整理汇总了C++中ErrorInfo::hasError方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorInfo::hasError方法的具体用法?C++ ErrorInfo::hasError怎么用?C++ ErrorInfo::hasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorInfo
的用法示例。
在下文中一共展示了ErrorInfo::hasError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate
void ClangCompilationDatabaseGenerator::generate()
{
for (const Project &theProject : project().projects.values()) {
QJsonArray database;
const ProjectData projectData = theProject.projectData();
const QString buildDir = projectData.buildDirectory();
for (const ProductData &productData : projectData.allProducts()) {
for (const GroupData &groupData : productData.groups()) {
for (const ArtifactData &sourceArtifact : groupData.allSourceArtifacts()) {
if (!hasValidInputFileTag(sourceArtifact.fileTags()))
continue;
const QString filePath = sourceArtifact.filePath();
ErrorInfo errorInfo;
const RuleCommandList rules = theProject.ruleCommands(productData, filePath,
QStringLiteral("obj"),
&errorInfo);
if (errorInfo.hasError())
throw errorInfo;
for (const RuleCommand &rule : rules) {
if (rule.type() != RuleCommand::ProcessCommandType)
continue;
database.append(createEntry(filePath, buildDir, rule));
}
}
}
}
writeProjectDatabase(QDir(buildDir).filePath(DefaultDatabaseFileName), database);
}
}
示例2: start
void InternalSetupProjectJob::start()
{
BuildGraphLocker *bgLocker = m_existingProject ? m_existingProject->bgLocker : 0;
try {
const ErrorInfo err = m_parameters.expandBuildConfiguration();
if (err.hasError())
throw err;
const QString projectId = TopLevelProject::deriveId(m_parameters.topLevelProfile(),
m_parameters.finalBuildConfigurationTree());
const QString buildDir
= TopLevelProject::deriveBuildDirectory(m_parameters.buildRoot(), projectId);
if (m_existingProject && m_existingProject->buildDirectory != buildDir)
m_existingProject.clear();
if (!m_existingProject) {
bgLocker = new BuildGraphLocker(ProjectBuildData::deriveBuildGraphFilePath(buildDir,
projectId),
logger());
}
execute();
if (m_existingProject)
m_existingProject->bgLocker = 0;
m_newProject->bgLocker = bgLocker;
} catch (const ErrorInfo &error) {
m_newProject.clear();
setError(error);
if (!m_existingProject)
delete bgLocker;
}
emit finished(this);
}
示例3: dumpNodesTree
void CommandLineFrontend::dumpNodesTree()
{
QFile stdOut;
stdOut.open(stdout, QIODevice::WriteOnly);
const ErrorInfo error = m_projects.front().dumpNodesTree(stdOut, productsToUse()
.value(m_projects.front()));
if (error.hasError())
throw error;
}
示例4: testProfiles
void TestTools::testProfiles()
{
TemporaryProfile tpp("parent", m_settings);
Profile parentProfile = tpp.p;
TemporaryProfile tpc("child", m_settings);
Profile childProfile = tpc.p;
parentProfile.removeBaseProfile();
parentProfile.remove("testKey");
QCOMPARE(parentProfile.value("testKey", "none").toString(), QLatin1String("none"));
parentProfile.setValue("testKey", "testValue");
QCOMPARE(parentProfile.value("testKey").toString(), QLatin1String("testValue"));
childProfile.remove("testKey");
childProfile.removeBaseProfile();
QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("none"));
childProfile.setBaseProfile("parent");
QCOMPARE(childProfile.value("testKey").toString(), QLatin1String("testValue"));
// Change base profile and check if the inherited value also changes.
TemporaryProfile tpf("foo", m_settings);
Profile fooProfile = tpf.p;
fooProfile.setValue("testKey", "gnampf");
childProfile.setBaseProfile("foo");
QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("gnampf"));
ErrorInfo errorInfo;
childProfile.setBaseProfile("SmurfAlongWithMe");
childProfile.value("blubb", QString(), &errorInfo);
QVERIFY(errorInfo.hasError());
errorInfo.clear();
childProfile.setBaseProfile("parent");
parentProfile.setBaseProfile("child");
QVERIFY(!childProfile.value("blubb", QString(), &errorInfo).isValid());
QVERIFY(errorInfo.hasError());
QVERIFY(!childProfile.allKeys(Profile::KeySelectionNonRecursive).isEmpty());
errorInfo.clear();
QVERIFY(childProfile.allKeys(Profile::KeySelectionRecursive, &errorInfo).isEmpty());
QVERIFY(errorInfo.hasError());
}
示例5: expandedBuildConfigurationInternal
static QVariantMap expandedBuildConfigurationInternal(const QString &settingsBaseDir,
const QString &profileName, const QString &buildVariant)
{
Settings settings(settingsBaseDir);
QVariantMap buildConfig;
// (1) Values from profile, if given.
if (!profileName.isEmpty()) {
ErrorInfo err;
const Profile profile(profileName, &settings);
const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive, &err);
if (err.hasError())
throw err;
if (profileKeys.isEmpty())
throw ErrorInfo(Internal::Tr::tr("Unknown or empty profile '%1'.").arg(profileName));
foreach (const QString &profileKey, profileKeys) {
buildConfig.insert(profileKey, profile.value(profileKey, QVariant(), &err));
if (err.hasError())
throw err;
}
示例6: generate
void CommandLineFrontend::generate()
{
QBS_CHECK(!!m_generator);
const ErrorInfo error = m_generator->generate(m_projects,
m_parser.buildConfigurations(),
m_parser.installOptions(QString()),
m_parser.settingsDir(),
ConsoleLogger::instance(m_settings));
if (error.hasError())
throw error;
}
示例7: testBuildConfigMerging
void TestTools::testBuildConfigMerging()
{
Settings settings((QString()));
TemporaryProfile tp(QLatin1String("tst_tools_profile"), &settings);
Profile profile = tp.p;
profile.setValue(QLatin1String("topLevelKey"), QLatin1String("topLevelValue"));
profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc"));
profile.setValue(QLatin1String("qbs.architecture"),
QLatin1String("Jean-Claude Pillemann"));
profile.setValue(QLatin1String("cpp.treatWarningsAsErrors"), true);
QVariantMap overrideMap;
overrideMap.insert(QLatin1String("qbs.toolchain"), QLatin1String("clang"));
overrideMap.insert(QLatin1String("qbs.installRoot"), QLatin1String("/blubb"));
SetupProjectParameters params;
params.setTopLevelProfile(profile.name());
params.setConfigurationName(QLatin1String("debug"));
params.setOverriddenValues(overrideMap);
const ErrorInfo error = params.expandBuildConfiguration();
QVERIFY2(!error.hasError(), qPrintable(error.toString()));
const QVariantMap finalMap = params.finalBuildConfigurationTree();
QCOMPARE(finalMap.count(), 3);
QCOMPARE(finalMap.value(QLatin1String("topLevelKey")).toString(),
QString::fromLatin1("topLevelValue"));
const QVariantMap finalQbsMap = finalMap.value(QLatin1String("qbs")).toMap();
QCOMPARE(finalQbsMap.count(), 4);
QCOMPARE(finalQbsMap.value(QLatin1String("toolchain")).toString(),
QString::fromLatin1("clang"));
QCOMPARE(finalQbsMap.value(QLatin1String("configurationName")).toString(),
QString::fromLatin1("debug"));
QCOMPARE(finalQbsMap.value(QLatin1String("architecture")).toString(),
QString::fromLatin1("Jean-Claude Pillemann"));
QCOMPARE(finalQbsMap.value(QLatin1String("installRoot")).toString(), QLatin1String("/blubb"));
const QVariantMap finalCppMap = finalMap.value(QLatin1String("cpp")).toMap();
QCOMPARE(finalCppMap.count(), 1);
QCOMPARE(finalCppMap.value(QLatin1String("treatWarningsAsErrors")).toBool(), true);
}