forked from qt-creator/qt-creator
Add a public method which reads the content of pro file from string
Rev-by: Oswald Buddenhagen <oswald.buddenhagen@trolltech.com>
This commit is contained in:
@@ -134,6 +134,8 @@ public:
|
|||||||
/////////////// Reading pro file
|
/////////////// Reading pro file
|
||||||
|
|
||||||
bool read(ProFile *pro);
|
bool read(ProFile *pro);
|
||||||
|
bool read(ProFile *pro, const QString &content);
|
||||||
|
bool read(ProFile *pro, QTextStream *ts);
|
||||||
|
|
||||||
ProBlock *currentBlock();
|
ProBlock *currentBlock();
|
||||||
void updateItem();
|
void updateItem();
|
||||||
@@ -284,6 +286,19 @@ bool ProFileEvaluator::Private::read(ProFile *pro)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextStream ts(&file);
|
||||||
|
return read(pro, &ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProFileEvaluator::Private::read(ProFile *pro, const QString &content)
|
||||||
|
{
|
||||||
|
QString str(content);
|
||||||
|
QTextStream ts(&str, QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
return read(pro, &ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProFileEvaluator::Private::read(ProFile *pro, QTextStream *ts)
|
||||||
|
{
|
||||||
// Parser state
|
// Parser state
|
||||||
m_block = 0;
|
m_block = 0;
|
||||||
m_commentItem = 0;
|
m_commentItem = 0;
|
||||||
@@ -295,9 +310,8 @@ bool ProFileEvaluator::Private::read(ProFile *pro)
|
|||||||
m_blockstack.clear();
|
m_blockstack.clear();
|
||||||
m_blockstack.push(pro);
|
m_blockstack.push(pro);
|
||||||
|
|
||||||
QTextStream ts(&file);
|
while (!ts->atEnd()) {
|
||||||
while (!ts.atEnd()) {
|
QString line = ts->readLine();
|
||||||
QString line = ts.readLine();
|
|
||||||
if (!parseLine(line)) {
|
if (!parseLine(line)) {
|
||||||
q->errorMessage(format(".pro parse failure."));
|
q->errorMessage(format(".pro parse failure."));
|
||||||
return false;
|
return false;
|
||||||
@@ -2629,6 +2643,11 @@ bool ProFileEvaluator::queryProFile(ProFile *pro)
|
|||||||
return d->read(pro);
|
return d->read(pro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProFileEvaluator::queryProFile(ProFile *pro, const QString &content)
|
||||||
|
{
|
||||||
|
return d->read(pro, content);
|
||||||
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::accept(ProFile *pro)
|
bool ProFileEvaluator::accept(ProFile *pro)
|
||||||
{
|
{
|
||||||
return pro->Accept(d);
|
return pro->Accept(d);
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
void setParsePreAndPostFiles(bool on); // Default is true
|
void setParsePreAndPostFiles(bool on); // Default is true
|
||||||
|
|
||||||
bool queryProFile(ProFile *pro);
|
bool queryProFile(ProFile *pro);
|
||||||
|
bool queryProFile(ProFile *pro, const QString &content); // the same as above but the content is read from "content" string, not from filesystem
|
||||||
bool accept(ProFile *pro);
|
bool accept(ProFile *pro);
|
||||||
|
|
||||||
void addVariables(const QHash<QString, QStringList> &variables);
|
void addVariables(const QHash<QString, QStringList> &variables);
|
||||||
|
|||||||
Reference in New Issue
Block a user