diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 5183a9edb43a55e4bf4ebd9e7039faa565f55b7b..295e094a9ce80e7f3b350a09e302a6d2e9053566 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -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); diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 5fe787953c9b59af923256ee202a9dd4747f6269..9bd88c0c03d0dac3a4086aceb4fdd6c53d1183c6 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -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);