本文整理汇总了C++中ProFile类的典型用法代码示例。如果您正苦于以下问题:C++ ProFile类的具体用法?C++ ProFile怎么用?C++ ProFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProFile类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: baseDir
void tst_ProFileWriter::multiVar()
{
QDir baseDir(BASE_DIR);
QString input = QLatin1String(
"SOURCES = foo bar\n"
"# comment line\n"
"HEADERS = baz bak"
);
QStringList lines = input.split(QLatin1String("\n"));
QString output = QLatin1String(
"SOURCES = bar\n"
"# comment line\n"
"HEADERS = baz"
);
QStringList files; files
<< QString::fromLatin1(BASE_DIR "/foo")
<< QString::fromLatin1(BASE_DIR "/bak");
QStringList vars; vars << QLatin1String("SOURCES") << QLatin1String("HEADERS");
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(input, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, baseDir, files, vars);
proFile->deref();
QCOMPARE(lines.join(QLatin1String("\n")), output);
}
示例2: locker
ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
{
ProFile *pro;
if ((flags & ParseUseCache) && m_cache) {
ProFileCache::Entry *ent;
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&m_cache->mutex);
#endif
QHash<QString, ProFileCache::Entry>::Iterator it = m_cache->parsed_files.find(fileName);
if (it != m_cache->parsed_files.end()) {
ent = &*it;
#ifdef PROPARSER_THREAD_SAFE
if (ent->locker && !ent->locker->done) {
++ent->locker->waiters;
QThreadPool::globalInstance()->releaseThread();
ent->locker->cond.wait(locker.mutex());
QThreadPool::globalInstance()->reserveThread();
if (!--ent->locker->waiters) {
delete ent->locker;
ent->locker = 0;
}
}
#endif
if ((pro = ent->pro))
pro->ref();
} else {
ent = &m_cache->parsed_files[fileName];
#ifdef PROPARSER_THREAD_SAFE
ent->locker = new ProFileCache::Entry::Locker;
locker.unlock();
#endif
pro = new ProFile(fileName);
if (!read(pro, flags)) {
delete pro;
pro = 0;
} else {
pro->itemsRef()->squeeze();
pro->ref();
}
ent->pro = pro;
#ifdef PROPARSER_THREAD_SAFE
locker.relock();
if (ent->locker->waiters) {
ent->locker->done = true;
ent->locker->cond.wakeAll();
} else {
delete ent->locker;
ent->locker = 0;
}
#endif
}
} else {
pro = new ProFile(fileName);
if (!read(pro, flags)) {
delete pro;
pro = 0;
}
}
return pro;
}
示例3: evaluate
static int evaluate(const QString &fileName, const QString &in_pwd, const QString &out_pwd,
bool cumulative, QMakeGlobals *option, QMakeParser *parser, int level)
{
static QSet<QString> visited;
if (visited.contains(fileName))
return 0;
visited.insert(fileName);
ProFileEvaluator visitor(option, parser, &evalHandler);
#ifdef PROEVALUATOR_CUMULATIVE
visitor.setCumulative(cumulative);
#endif
visitor.setOutputDir(out_pwd);
ProFile *pro;
if (!(pro = parser->parsedProFile(fileName)))
return 2;
if (!visitor.accept(pro)) {
pro->deref();
return 2;
}
if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) {
QStringList subdirs = visitor.values(QLatin1String("SUBDIRS"));
subdirs.removeDuplicates();
foreach (const QString &subDirVar, subdirs) {
QString realDir;
const QString subDirKey = subDirVar + QLatin1String(".subdir");
const QString subDirFileKey = subDirVar + QLatin1String(".file");
if (visitor.contains(subDirKey))
realDir = QFileInfo(value(visitor, subDirKey)).filePath();
else if (visitor.contains(subDirFileKey))
realDir = QFileInfo(value(visitor, subDirFileKey)).filePath();
else
realDir = subDirVar;
QFileInfo info(realDir);
if (!info.isAbsolute())
info.setFile(in_pwd + QLatin1Char('/') + realDir);
if (info.isDir())
info.setFile(QString::fromLatin1("%1/%2.pro").arg(info.filePath(), info.fileName()));
if (!info.exists()) {
qDebug() << "Could not find sub dir" << info.filePath();
continue;
}
QString inFile = QDir::cleanPath(info.absoluteFilePath()),
inPwd = QDir::cleanPath(info.path()),
outPwd = QDir::cleanPath(QDir(out_pwd).absoluteFilePath(
QDir(in_pwd).relativeFilePath(info.path())));
int nlevel = level;
if (nlevel >= 0) {
printf("%sReading %s%s\n", QByteArray().fill(' ', nlevel).constData(),
qPrintable(inFile), (inPwd == outPwd) ? "" :
qPrintable(QString(QLatin1String(" [") + outPwd + QLatin1Char(']'))));
fflush(stdout);
nlevel++;
}
evaluate(inFile, inPwd, outPwd, cumulative, option, parser, nlevel);
}
示例4: expand
ProString QMakeProject::expand(const QString &expr, const QString &where, int line)
{
ProString ret;
ProFile *pro = m_parser->parsedProBlock(expr, where, line, QMakeParser::ValueGrammar);
if (pro->isOk()) {
m_current.pro = pro;
m_current.line = 0;
const ushort *tokPtr = pro->tokPtr();
ProStringList result = expandVariableReferences(tokPtr, 1, true);
if (!result.isEmpty())
ret = result.at(0);
}
pro->deref();
return ret;
}
示例5: QFETCH
void tst_ProFileWriter::removes()
{
QFETCH(QStringList, values);
QFETCH(QString, input);
QFETCH(QString, output);
QStringList lines = input.split(QLatin1String("\n"));
QStringList vars; vars << QLatin1String("SOURCES");
QMakeParser parser(0, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QLatin1String(BASE_DIR "/test.pro"), input);
QVERIFY(proFile);
Qt4ProjectManager::Internal::ProWriter::removeVarValues(proFile, &lines, values, vars);
proFile->deref();
QCOMPARE(lines.join(QLatin1String("\n")), output);
}
示例6: QLatin1String
void tst_ProFileWriter::removeFiles()
{
QString input = QLatin1String(
"SOURCES = foo.cpp sub/bar.cpp"
);
QStringList lines = input.split(QLatin1String("\n"));
QString output = QLatin1String(
"SOURCES = foo.cpp"
);
QMakeParser parser(0, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QLatin1String(BASE_DIR "/test.pro"), input);
QVERIFY(proFile);
Qt4ProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, QDir(BASE_DIR),
QStringList() << QString::fromLatin1(BASE_DIR "/sub/bar.cpp"),
QStringList() << QLatin1String("SOURCES") << QLatin1String("HEADERS"));
proFile->deref();
QCOMPARE(lines.join(QLatin1String("\n")), output);
}
示例7: QLatin1String
void tst_ProFileWriter::addFiles()
{
QString input = QLatin1String(
"SOURCES = foo.cpp"
);
QStringList lines = input.split(QLatin1String("\n"));
QString output = QLatin1String(
"SOURCES = foo.cpp \\\n"
" sub/bar.cpp"
);
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(input, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::addFiles(proFile, &lines,
QStringList() << QString::fromLatin1(BASE_DIR "/sub/bar.cpp"),
QLatin1String("SOURCES"));
proFile->deref();
QCOMPARE(lines.join(QLatin1String("\n")), output);
}
示例8: QTC_ASSERT
void S60PublisherOvi::completeCreation()
{
#if 0 // FIXME: This needs serious reworking!
// set active target
m_activeTargetOfProject = qobject_cast<Qt4SymbianTarget *>(m_qt4bc->target());
QTC_ASSERT(m_activeTargetOfProject, return);
//set up project
m_qt4project = m_activeTargetOfProject->qt4Project();
// set up pro file reader
m_reader = m_qt4project->createProFileReader(m_qt4project->rootQt4ProjectNode(), m_qt4bc);
//m_reader->setCumulative(false); // todo need to reenable that, after fixing parsing for symbian scopes
ProFile *profile = m_reader->parsedProFile(m_qt4project->rootProjectNode()->path());
m_reader->accept(profile, QMakeEvaluator::LoadProOnly);
profile->deref();
// set up process for creating the resulting SIS files
ProjectExplorer::AbstractProcessStep * makeStep = m_qt4bc->makeStep();
makeStep->init();
const ProjectExplorer::ProcessParameters * const makepp = makeStep->processParameters();
ProjectExplorer::AbstractProcessStep *qmakeStep = m_qt4bc->qmakeStep();
qmakeStep->init();
const ProjectExplorer::ProcessParameters * const qmakepp = qmakeStep->processParameters();
m_publishSteps.clear();
const QChar space = QLatin1Char(' ');
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + QLatin1String(" clean -w"),
tr("Clean"),
false));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
qmakepp->effectiveCommand() + space + qmakepp->arguments(),
tr("qmake")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + space + makepp->arguments(),
tr("Build")));
if (isDynamicLibrary(*m_qt4project)) {
const QString freezeArg = QLatin1String("freeze-") + makepp->arguments();
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + space + freezeArg,
tr("Freeze")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + QLatin1String(" clean -w"),
tr("Secondary clean"),
false));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
qmakepp->effectiveCommand() + space + qmakepp->arguments(),
tr("Secondary qmake")));
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + space + makepp->arguments(),
tr("Secondary build")));
}
QString signArg = QLatin1String("unsigned_installer_sis");
if (m_qt4bc->qtVersion()->qtVersion() == QtSupport::QtVersionNumber(4,6,3) )
signArg = QLatin1String("installer_sis");
m_publishSteps.append(new S60CommandPublishStep(*m_qt4bc,
makepp->effectiveCommand() + space + signArg,
tr("Making SIS file")));
// set up access to vendor names
QStringList deploymentLevelVars = m_reader->values(QLatin1String("DEPLOYMENT"));
QStringList vendorInfoVars;
QStringList valueLevelVars;
foreach (const QString &deploymentLevelVar, deploymentLevelVars) {
vendorInfoVars = m_reader->values(deploymentLevelVar+QLatin1String(".pkg_prerules"));
foreach (const QString &vendorInfoVar, vendorInfoVars) {
valueLevelVars = m_reader->values(vendorInfoVar);
foreach (const QString &valueLevelVar, valueLevelVars) {
if (valueLevelVar.startsWith(QLatin1String("%{\""))) {
m_vendorInfoVariable = vendorInfoVar;
break;
}
}
}
示例9: main
int main(int argc, char **argv)
{
#ifdef QT_BOOTSTRAPPED
initBinaryDir(
#ifndef Q_OS_WIN
argv[0]
#endif
);
#else
QCoreApplication app(argc, argv);
#ifndef Q_OS_WIN32
QTranslator translator;
QTranslator qtTranslator;
QString sysLocale = QLocale::system().name();
QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
&& qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
app.installTranslator(&translator);
app.installTranslator(&qtTranslator);
}
#endif // Q_OS_WIN32
#endif // QT_BOOTSTRAPPED
ConversionData cd;
cd.m_verbose = true; // the default is true starting with Qt 4.2
bool removeIdentical = false;
Translator tor;
QStringList inputFiles;
QString outputFile;
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "-compress")) {
cd.m_saveMode = SaveStripped;
continue;
} else if (!strcmp(argv[i], "-idbased")) {
cd.m_idBased = true;
continue;
} else if (!strcmp(argv[i], "-nocompress")) {
cd.m_saveMode = SaveEverything;
continue;
} else if (!strcmp(argv[i], "-removeidentical")) {
removeIdentical = true;
continue;
} else if (!strcmp(argv[i], "-nounfinished")) {
cd.m_ignoreUnfinished = true;
continue;
} else if (!strcmp(argv[i], "-markuntranslated")) {
if (i == argc - 1) {
printUsage();
return 1;
}
cd.m_unTrPrefix = QString::fromLocal8Bit(argv[++i]);
} else if (!strcmp(argv[i], "-silent")) {
cd.m_verbose = false;
continue;
} else if (!strcmp(argv[i], "-verbose")) {
cd.m_verbose = true;
continue;
} else if (!strcmp(argv[i], "-version")) {
printOut(LR::tr("lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)));
return 0;
} else if (!strcmp(argv[i], "-qm")) {
if (i == argc - 1) {
printUsage();
return 1;
}
outputFile = QString::fromLocal8Bit(argv[++i]);
} else if (!strcmp(argv[i], "-help")) {
printUsage();
return 0;
} else if (argv[i][0] == '-') {
printUsage();
return 1;
} else {
inputFiles << QString::fromLocal8Bit(argv[i]);
}
}
if (inputFiles.isEmpty()) {
printUsage();
return 1;
}
foreach (const QString &inputFile, inputFiles) {
if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive)
|| inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) {
QFileInfo fi(inputFile);
parseHandler.verbose = evalHandler.verbose = cd.isVerbose();
ProFileOption option;
#ifdef QT_BOOTSTRAPPED
option.initProperties(binDir + QLatin1String("/qmake"));
#else
option.initProperties(app.applicationDirPath() + QLatin1String("/qmake"));
#endif
ProFileParser parser(0, &parseHandler);
ProFileEvaluator visitor(&option, &parser, &evalHandler);
ProFile *pro;
if (!(pro = parser.parsedProFile(QDir::cleanPath(fi.absoluteFilePath())))) {
//.........这里部分代码省略.........