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:
Jarek Kobus
2009-07-07 13:13:12 +02:00
parent 6e3bc2c2df
commit 42adcb9116
2 changed files with 23 additions and 3 deletions

View File

@@ -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);