Commit 42adcb91 authored by Jarek Kobus's avatar Jarek Kobus

Add a public method which reads the content of pro file from string

Rev-by: default avatarOswald Buddenhagen <oswald.buddenhagen@trolltech.com>
parent 6e3bc2c2
......@@ -134,6 +134,8 @@ public:
/////////////// Reading pro file
bool read(ProFile *pro);
bool read(ProFile *pro, const QString &content);
bool read(ProFile *pro, QTextStream *ts);
ProBlock *currentBlock();
void updateItem();
......@@ -284,6 +286,19 @@ bool ProFileEvaluator::Private::read(ProFile *pro)
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
m_block = 0;
m_commentItem = 0;
......@@ -295,9 +310,8 @@ bool ProFileEvaluator::Private::read(ProFile *pro)
m_blockstack.clear();
m_blockstack.push(pro);
QTextStream ts(&file);
while (!ts.atEnd()) {
QString line = ts.readLine();
while (!ts->atEnd()) {
QString line = ts->readLine();
if (!parseLine(line)) {
q->errorMessage(format(".pro parse failure."));
return false;
......@@ -2629,6 +2643,11 @@ bool ProFileEvaluator::queryProFile(ProFile *pro)
return d->read(pro);
}
bool ProFileEvaluator::queryProFile(ProFile *pro, const QString &content)
{
return d->read(pro, content);
}
bool ProFileEvaluator::accept(ProFile *pro)
{
return pro->Accept(d);
......
......@@ -69,6 +69,7 @@ public:
void setParsePreAndPostFiles(bool on); // Default is true
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);
void addVariables(const QHash<QString, QStringList> &variables);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment