Add an overload to Moc to allow reading from a QIODevice.

This allows external code to provide the input data, such
as a bootstrapped version of qdbuscpp2xml.

Change-Id: I163062efc6495b3ab92573f94523967a67601191
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Stephen Kelly 2012-03-08 21:34:14 +01:00 committed by Qt by Nokia
parent 08c1cb5c5a
commit b05139b2dc
2 changed files with 9 additions and 2 deletions

View File

@ -937,10 +937,15 @@ Symbols Preprocessor::preprocessed(const QByteArray &filename, FILE *file)
{
QFile qfile;
qfile.open(file, QFile::ReadOnly);
QByteArray input = qfile.readAll();
return preprocessed(filename, &qfile);
}
Symbols Preprocessor::preprocessed(const QByteArray &filename, QIODevice *file)
{
QByteArray input = file->readAll();
if (input.isEmpty())
return symbols;
// phase 1: get rid of backslash-newlines
input = cleaned(input);

View File

@ -62,6 +62,7 @@ typedef SubArray MacroName;
typedef QHash<MacroName, Macro> Macros;
typedef QVector<MacroName> MacroSafeSet;
class QIODevice;
class Preprocessor : public Parser
{
@ -80,6 +81,7 @@ public:
QSet<QByteArray> preprocessedIncludes;
Macros macros;
Symbols preprocessed(const QByteArray &filename, FILE *file);
Symbols preprocessed(const QByteArray &filename, QIODevice *device);
void skipUntilEndif();