tools/qdbus/tools/qdbusxml2cpp/qdbusxml2cpp.cpp File Reference

#include <QtCore/qbytearray.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qfile.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qset.h>
#include <QtDBus>
#include "private/qdbusmetaobject_p.h"
#include "private/qdbusintrospection_p.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

Include dependency graph for qdbusxml2cpp.cpp:

Go to the source code of this file.

Defines

#define PROGRAMNAME   "dbusxml2cpp"
#define PROGRAMVERSION   "0.6"
#define PROGRAMCOPYRIGHT   "Copyright (C) 2006 Trolltech ASA. All rights reserved."
#define ANNOTATION_NO_WAIT   "org.freedesktop.DBus.Method.NoReply"

Enumerations

enum  ClassType

Functions

static void showHelp ()
static void showVersion ()
static QString nextArg (QStringList &args, int i, char opt)
static void parseCmdLine (QStringList args)
static QDBusIntrospection::Interfaces readInput ()
static void cleanInterfaces (QDBusIntrospection::Interfaces &interfaces)
static QString header (const QString &name)
static QString cpp (const QString &name)
static QString moc (const QString &name)
static QTextStreamwriteHeader (QTextStream &ts, bool changesWillBeLost)
static QString classNameForInterface (const QString &interface, ClassType classType)
static QByteArray qtTypeName (const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId=-1, const char *direction="Out")
static QString nonConstRefArg (const QByteArray &arg)
static QString templateArg (const QByteArray &arg)
static QString constRefArg (const QByteArray &arg)
static QStringList makeArgNames (const QDBusIntrospection::Arguments &inputArgs, const QDBusIntrospection::Arguments &outputArgs=QDBusIntrospection::Arguments())
static void writeArgList (QTextStream &ts, const QStringList &argNames, const QDBusIntrospection::Annotations &annotations, const QDBusIntrospection::Arguments &inputArgs, const QDBusIntrospection::Arguments &outputArgs=QDBusIntrospection::Arguments())
static QString propertyGetter (const QDBusIntrospection::Property &property)
static QString propertySetter (const QDBusIntrospection::Property &property)
static QString stringify (const QString &data)
static void openFile (const QString &fileName, QFile &file)
static void writeProxy (const QString &filename, const QDBusIntrospection::Interfaces &interfaces)
static void writeAdaptor (const QString &filename, const QDBusIntrospection::Interfaces &interfaces)
int main (int argc, char **argv)

Variables

static QString globalClassName
static QString parentClassName
static QString proxyFile
static QString adaptorFile
static QString inputFile
static bool skipNamespaces
static bool verbose
static bool includeMocs
static QString commandLine
static QStringList includes
static QStringList wantedInterfaces
static const char help []
static const char includeList []
static const char forwardDeclarations []


Define Documentation

#define ANNOTATION_NO_WAIT   "org.freedesktop.DBus.Method.NoReply"

Definition at line 46 of file qdbusxml2cpp.cpp.

#define PROGRAMCOPYRIGHT   "Copyright (C) 2006 Trolltech ASA. All rights reserved."

Definition at line 44 of file qdbusxml2cpp.cpp.

#define PROGRAMNAME   "dbusxml2cpp"

Definition at line 42 of file qdbusxml2cpp.cpp.

#define PROGRAMVERSION   "0.6"

Definition at line 43 of file qdbusxml2cpp.cpp.


Enumeration Type Documentation

enum ClassType

Definition at line 296 of file qdbusxml2cpp.cpp.

00296 { Proxy, Adaptor };


Function Documentation

static QString classNameForInterface ( const QString interface,
ClassType  classType 
) [static]

Definition at line 297 of file qdbusxml2cpp.cpp.

References globalClassName, QString::isEmpty(), QList< T >::last(), Proxy, QString::split(), and QString::toUpper().

Referenced by writeAdaptor(), and writeProxy().

00298 {
00299     if (!globalClassName.isEmpty())
00300         return globalClassName;
00301 
00302     QStringList parts = interface.split(QLatin1Char('.'));
00303 
00304     QString retval;
00305     if (classType == Proxy)
00306         foreach (QString part, parts) {
00307             part[0] = part[0].toUpper();
00308             retval += part;
00309         }
00310     else {
00311         retval = parts.last();
00312         retval[0] = retval[0].toUpper();
00313     }
00314 
00315     if (classType == Proxy)
00316         retval += QLatin1String("Interface");
00317     else
00318         retval += QLatin1String("Adaptor");
00319 
00320     return retval;
00321 }

Here is the call graph for this function:

static void cleanInterfaces ( QDBusIntrospection::Interfaces interfaces  )  [static]

Definition at line 218 of file qdbusxml2cpp.cpp.

References QMap< Key, T >::begin(), QStringList::contains(), QMap< Key, T >::end(), QMap< Key, T >::erase(), QList< T >::isEmpty(), and wantedInterfaces.

Referenced by main().

00219 {
00220     if (!wantedInterfaces.isEmpty()) {
00221         QDBusIntrospection::Interfaces::Iterator it = interfaces.begin();
00222         while (it != interfaces.end())
00223             if (!wantedInterfaces.contains(it.key()))
00224                 it = interfaces.erase(it);
00225             else
00226                 ++it;
00227     }
00228 }

Here is the call graph for this function:

static QString constRefArg ( const QByteArray arg  )  [static]

Definition at line 356 of file qdbusxml2cpp.cpp.

References QString::arg(), and QByteArray::startsWith().

Referenced by writeAdaptor(), writeArgList(), and writeProxy().

00357 {
00358     if (!arg.startsWith('Q'))
00359         return QLatin1String(arg + ' ');
00360     else
00361         return QString( QLatin1String("const %1 &") ).arg( QLatin1String(arg) );
00362 }

Here is the call graph for this function:

static QString cpp ( const QString name  )  [static]

Definition at line 247 of file qdbusxml2cpp.cpp.

References QString::append(), QString::endsWith(), QString::isEmpty(), QList< T >::last(), and name.

Referenced by qt_read_xpm_image_or_array(), write_xpm_image(), writeAdaptor(), and writeProxy().

00248 {
00249     QStringList parts = name.split(QLatin1Char(':'));
00250     QString retval = parts.last();
00251 
00252     if (retval.isEmpty() || retval == QLatin1String("-"))
00253         return retval;
00254 
00255     if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
00256         !retval.endsWith(QLatin1String(".cc")))
00257         retval.append(QLatin1String(".cpp"));
00258 
00259     return retval;
00260 }

Here is the call graph for this function:

static QString header ( const QString name  )  [static]

Definition at line 231 of file qdbusxml2cpp.cpp.

References QString::append(), QString::endsWith(), QList< T >::first(), QString::isEmpty(), and name.

Referenced by CPP::WriteIncludes::acceptCustomWidget(), CPP::WriteIncludes::acceptUI(), CPP::WriteIncludes::add(), QTextCodec::codecForHtml(), qdesigner_internal::QDesignerResource::createCustomWidgets(), Ui3Reader::createFormDecl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QCommonStyle::drawControl(), QCommonStyle::drawPrimitive(), QWindowsXPStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QPdfEnginePrivate::embedFont(), QPSPrintEnginePrivate::emitHeader(), QTableModel::ensureSorted(), QCalendarModel::formatForCell(), Ui3Reader::generateUi4(), QHttp::get(), Q3Http::get(), getStyleOption(), Q3Http::head(), QHttp::head(), Q3ListViewExtraInfo::loadWidgetExtraInfo(), moc(), Q3Header::mouseDoubleClickEvent(), qdesigner_internal::PaletteEditor::on_detailsRadio_clicked(), Q3Http::operationGet(), Q3Http::operationPut(), QHttpRequestHeader::operator=(), QHttpResponseHeader::operator=(), Q3Http::post(), QHttp::post(), Uic::printDependencies(), Q3HttpHeader::Q3HttpHeader(), QHttpHeader::QHttpHeader(), QHttpRequestHeader::QHttpRequestHeader(), QHttpResponseHeader::QHttpResponseHeader(), QHttp::request(), Q3Http::request(), QTableView::resizeColumnToContents(), QTableView::resizeRowToContents(), qdesigner_internal::QDesignerResource::saveCustomWidgets(), Q3ListViewExtraInfo::saveWidgetExtraInfo(), QTableViewPrivate::sectionSpanEndLogical(), QTableViewPrivate::sectionSpanSize(), QTableView::setHorizontalHeader(), QTableModel::setItem(), QTableView::setVerticalHeader(), MainWindow::sizeHint(), QTableViewPrivate::spanContainsSection(), QCommonStyle::subElementRect(), Q3Table::updateHeaderAndResizeContents(), QDBusMetaObjectGenerator::write(), writeAdaptor(), and writeProxy().

00232 {
00233     QStringList parts = name.split(QLatin1Char(':'));
00234     QString retval = parts.first();
00235 
00236     if (retval.isEmpty() || retval == QLatin1String("-"))
00237         return retval;
00238 
00239     if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
00240         !retval.endsWith(QLatin1String(".cc")))
00241         retval.append(QLatin1String(".h"));
00242 
00243     return retval;
00244 }

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 1065 of file qdbusxml2cpp.cpp.

References adaptorFile, QCoreApplication::arguments(), cleanInterfaces(), QString::isEmpty(), parseCmdLine(), proxyFile, readInput(), writeAdaptor(), and writeProxy().

01066 {
01067     QCoreApplication app(argc, argv);
01068     parseCmdLine(app.arguments());
01069 
01070     QDBusIntrospection::Interfaces interfaces = readInput();
01071     cleanInterfaces(interfaces);
01072 
01073     if (!proxyFile.isEmpty() || adaptorFile.isEmpty())
01074         writeProxy(proxyFile, interfaces);
01075 
01076     if (!adaptorFile.isEmpty())
01077         writeAdaptor(adaptorFile, interfaces);
01078 
01079     return 0;
01080 }

Here is the call graph for this function:

static QStringList makeArgNames ( const QDBusIntrospection::Arguments inputArgs,
const QDBusIntrospection::Arguments outputArgs = QDBusIntrospection::Arguments() 
) [static]

Definition at line 364 of file qdbusxml2cpp.cpp.

References QList< T >::at(), QStringList::contains(), QList< T >::count(), i, and name.

Referenced by writeAdaptor(), and writeProxy().

00367 {
00368     QStringList retval;
00369     for (int i = 0; i < inputArgs.count(); ++i) {
00370         const QDBusIntrospection::Argument &arg = inputArgs.at(i);
00371         QString name = arg.name;
00372         if (name.isEmpty())
00373             name = QString( QLatin1String("in%1") ).arg(i);
00374         while (retval.contains(name))
00375             name += QLatin1String("_");
00376         retval << name;
00377     }
00378     for (int i = 0; i < outputArgs.count(); ++i) {
00379         const QDBusIntrospection::Argument &arg = outputArgs.at(i);
00380         QString name = arg.name;
00381         if (name.isEmpty())
00382             name = QString( QLatin1String("out%1") ).arg(i);
00383         while (retval.contains(name))
00384             name += QLatin1String("_");
00385         retval << name;
00386     }
00387     return retval;
00388 }

Here is the call graph for this function:

static QString moc ( const QString name  )  [static]

Definition at line 263 of file qdbusxml2cpp.cpp.

References header(), QString::isEmpty(), QString::length(), name, and QString::truncate().

Referenced by main(), writeAdaptor(), and writeProxy().

00264 {
00265     QString retval = header(name);
00266     if (retval.isEmpty())
00267         return retval;
00268 
00269     retval.truncate(retval.length() - 1); // drop the h in .h
00270     retval += QLatin1String("moc");
00271     return retval;
00272 }

Here is the call graph for this function:

static QString nextArg ( QStringList args,
int  i,
char  opt 
) [static]

Definition at line 111 of file qdbusxml2cpp.cpp.

References QString::isEmpty(), printf, QList< T >::takeAt(), and QList< T >::value().

Referenced by parseCmdLine().

00112 {
00113     QString arg = args.value(i);
00114     if (arg.isEmpty()) {
00115         printf("-%c needs at least one argument\n", opt);
00116         exit(1);
00117     }
00118     return args.takeAt(i);
00119 }

Here is the call graph for this function:

static QString nonConstRefArg ( const QByteArray arg  )  [static]

Definition at line 343 of file qdbusxml2cpp.cpp.

Referenced by writeArgList().

00344 {
00345     return QLatin1String(arg + " &");
00346 }

static void openFile ( const QString fileName,
QFile file 
) [static]

Definition at line 460 of file qdbusxml2cpp.cpp.

References QIODevice::errorString(), QString::isEmpty(), QFile::open(), QFile::setFileName(), QIODevice::Text, QIODevice::Truncate, and QIODevice::WriteOnly.

Referenced by writeAdaptor(), and writeProxy().

00461 {
00462     if (fileName.isEmpty())
00463         return;
00464 
00465     bool isOk = false;
00466     if (fileName == QLatin1String("-")) {
00467         isOk = file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
00468     } else {
00469         file.setFileName(fileName);
00470         isOk = file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
00471     }
00472 
00473     if (!isOk)
00474         fprintf(stderr, "Unable to open '%s': %s\n", qPrintable(fileName),
00475                 qPrintable(file.errorString()));
00476 }

Here is the call graph for this function:

static void parseCmdLine ( QStringList  args  )  [static]

Definition at line 121 of file qdbusxml2cpp.cpp.

References adaptorFile, QList< T >::at(), QString::at(), c, commandLine, QList< T >::count(), globalClassName, i, includeMocs, includes, inputFile, QList< T >::isEmpty(), QStringList::join(), QString::length(), nextArg(), parentClassName, printf, PROGRAMNAME, proxyFile, showHelp(), showVersion(), skipNamespaces, QString::startsWith(), QList< T >::takeAt(), QList< T >::takeFirst(), QChar::toLatin1(), verbose, and wantedInterfaces.

00122 {
00123     args.takeFirst();
00124 
00125     commandLine = QLatin1String(PROGRAMNAME " ");
00126     commandLine += args.join(QLatin1String(" "));
00127 
00128     int i = 0;
00129     while (i < args.count()) {
00130 
00131         if (!args.at(i).startsWith(QLatin1Char('-'))) {
00132             ++i;
00133             continue;
00134         }
00135         QString arg = args.takeAt(i);
00136 
00137         char c = '\0';
00138         if (arg.length() == 2)
00139             c = arg.at(1).toLatin1();
00140         else if (arg == QLatin1String("--help"))
00141             c = 'h';
00142 
00143         switch (c) {
00144         case 'a':
00145             adaptorFile = nextArg(args, i, 'a');
00146             break;
00147 
00148         case 'c':
00149             globalClassName = nextArg(args, i, 'c');
00150             break;
00151 
00152         case 'v':
00153             verbose = true;
00154             break;
00155 
00156         case 'i':
00157             includes << nextArg(args, i, 'i');
00158             break;
00159 
00160         case 'l':
00161             parentClassName = nextArg(args, i, 'l');
00162             break;
00163 
00164         case 'm':
00165             includeMocs = true;
00166             break;
00167 
00168         case 'N':
00169             skipNamespaces = true;
00170             break;
00171 
00172         case '?':
00173         case 'h':
00174             showHelp();
00175             break;
00176 
00177         case 'V':
00178             showVersion();
00179             break;
00180 
00181         case 'p':
00182             proxyFile = nextArg(args, i, 'p');
00183             break;
00184 
00185         default:
00186             printf("unknown option: '%s'\n", qPrintable(arg));
00187             exit(1);
00188         }
00189     }
00190 
00191     if (!args.isEmpty())
00192         inputFile = args.takeFirst();
00193 
00194     wantedInterfaces << args;
00195 }

Here is the call graph for this function:

static QString propertyGetter ( const QDBusIntrospection::Property property  )  [static]

Definition at line 424 of file qdbusxml2cpp.cpp.

References QDBusIntrospection::Property::annotations, QString::isEmpty(), QDBusIntrospection::Property::name, and QString::toLower().

Referenced by writeAdaptor(), and writeProxy().

00425 {
00426     QString getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
00427     if (getter.isEmpty()) {
00428         getter =  property.name;
00429         getter[0] = getter[0].toLower();
00430     }
00431     return getter;
00432 }

Here is the call graph for this function:

static QString propertySetter ( const QDBusIntrospection::Property property  )  [static]

Definition at line 434 of file qdbusxml2cpp.cpp.

References QDBusIntrospection::Property::annotations, QString::isEmpty(), QDBusIntrospection::Property::name, and QString::toUpper().

Referenced by writeAdaptor(), and writeProxy().

00435 {
00436     QString setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
00437     if (setter.isEmpty()) {
00438         setter = QLatin1String("set") + property.name;
00439         setter[3] = setter[3].toUpper();
00440     }
00441     return setter;
00442 }

Here is the call graph for this function:

static QByteArray qtTypeName ( const QString signature,
const QDBusIntrospection::Annotations annotations,
int  paramId = -1,
const char *  direction = "Out" 
) [static]

Definition at line 323 of file qdbusxml2cpp.cpp.

References QString::arg(), direction, QString::fromLatin1(), QVariant::Invalid, QString::isEmpty(), QDBusMetaType::signatureToType(), QString::toLatin1(), type, QVariant::typeToName(), and QMap< Key, T >::value().

Referenced by writeAdaptor(), writeArgList(), and writeProxy().

00324 {
00325     int type = QDBusMetaType::signatureToType(signature.toLatin1());
00326     if (type == QVariant::Invalid) {
00327         QString annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
00328         if (paramId >= 0)
00329             annotationName += QString::fromLatin1(".%1%2").arg(direction).arg(paramId);
00330         QString qttype = annotations.value(annotationName);
00331         if (!qttype.isEmpty())
00332             return qttype.toLatin1();
00333 
00334         fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature));
00335         fprintf(stderr, "You should add <annotation name=\"%s\" value=\"<type>\"/> to the XML description\n",
00336                 qPrintable(annotationName));
00337         exit(1);
00338     }
00339 
00340     return QVariant::typeToName(QVariant::Type(type));
00341 }

Here is the call graph for this function:

static QDBusIntrospection::Interfaces readInput (  )  [static]

Definition at line 197 of file qdbusxml2cpp.cpp.

References data, QString::fromUtf8(), inputFile, QString::isEmpty(), QFile::open(), QDBusIntrospection::parseInterfaces(), QIODevice::readAll(), and QIODevice::ReadOnly.

Referenced by main().

00198 {
00199     QFile input(inputFile);
00200     if (inputFile.isEmpty() || inputFile == QLatin1String("-"))
00201         input.open(stdin, QIODevice::ReadOnly);
00202     else
00203         input.open(QIODevice::ReadOnly);
00204 
00205     QByteArray data = input.readAll();
00206 
00207     // check if the input is already XML
00208     data = data.trimmed();
00209     if (data.startsWith("<!DOCTYPE ") || data.startsWith("<?xml") ||
00210         data.startsWith("<node") || data.startsWith("<interface"))
00211         // already XML
00212         return QDBusIntrospection::parseInterfaces(QString::fromUtf8(data));
00213 
00214     fprintf(stderr, "Cannot process input. Stop.\n");
00215     exit(1);
00216 }

Here is the call graph for this function:

static void showHelp (  )  [static]

Definition at line 98 of file qdbusxml2cpp.cpp.

References help, and printf.

00099 {
00100     printf("%s", help);
00101     exit(0);
00102 }

static void showVersion (  )  [static]

Definition at line 104 of file qdbusxml2cpp.cpp.

References printf, PROGRAMNAME, and PROGRAMVERSION.

00105 {
00106     printf("%s version %s\n", PROGRAMNAME, PROGRAMVERSION);
00107     printf("D-Bus binding tool for Qt\n");
00108     exit(0);
00109 }

static QString stringify ( const QString data  )  [static]

Definition at line 444 of file qdbusxml2cpp.cpp.

References data, and i.

Referenced by writeAdaptor().

00445 {
00446     QString retval;
00447     int i;
00448     for (i = 0; i < data.length(); ++i) {
00449         retval += QLatin1Char('\"');
00450         for ( ; i < data.length() && data[i] != QLatin1Char('\n'); ++i)
00451             if (data[i] == QLatin1Char('\"'))
00452                 retval += QLatin1String("\\\"");
00453             else
00454                 retval += data[i];
00455         retval += QLatin1String("\\n\"\n");
00456     }
00457     return retval;
00458 }

static QString templateArg ( const QByteArray arg  )  [static]

Definition at line 348 of file qdbusxml2cpp.cpp.

References QByteArray::endsWith().

Referenced by writeProxy().

00349 {
00350     if (!arg.endsWith('>'))
00351         return QLatin1String(arg);
00352 
00353     return QLatin1String(arg + ' ');
00354 }

Here is the call graph for this function:

static void writeAdaptor ( const QString filename,
const QDBusIntrospection::Interfaces interfaces 
) [static]

Definition at line 764 of file qdbusxml2cpp.cpp.

References QDBusIntrospection::Property::access, Adaptor, ANNOTATION_NO_WAIT, QDBusIntrospection::Property::annotations, QDBusIntrospection::Signal::annotations, QString::arg(), QList< T >::at(), classNameForInterface(), constRefArg(), cpp(), QDateTime::currentDateTime(), QTextStream::endl(), QTextStream::flush(), forwardDeclarations, header(), i, include(), includeList, includeMocs, includes, QDBusIntrospection::Interface::introspection, QByteArray::isEmpty(), QString::isEmpty(), QString::lastIndexOf(), makeArgNames(), method, QDBusIntrospection::Interface::methods, QString::mid(), moc(), name, QDBusIntrospection::Signal::name, QDBusIntrospection::Property::name, QDBusIntrospection::Interface::name, openFile(), QDBusIntrospection::Signal::outputArgs, parentClassName, QDBusIntrospection::Interface::properties, propertyGetter(), propertySetter(), qtTypeName(), QDBusIntrospection::Property::Read, QString::replace(), QDBusIntrospection::Interface::signals_, stringify(), toTime_t(), QString::toUpper(), type, QDBusIntrospection::Property::type, QDBusIntrospection::Property::Write, QIODevice::write(), writeArgList(), and writeHeader().

Referenced by main().

00765 {
00766     // open the file
00767     QString headerName = header(filename);
00768     QByteArray headerData;
00769     QTextStream hs(&headerData);
00770 
00771     QString cppName = cpp(filename);
00772     QByteArray cppData;
00773     QTextStream cs(&cppData);
00774 
00775     // write the headers
00776     writeHeader(hs, false);
00777     if (cppName != headerName)
00778         writeHeader(cs, true);
00779 
00780     // include guards:
00781     QString includeGuard;
00782     if (!headerName.isEmpty() && headerName != QLatin1String("-")) {
00783         includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
00784         int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
00785         if (pos != -1)
00786             includeGuard = includeGuard.mid(pos + 1);
00787     } else {
00788         includeGuard = QLatin1String("QDBUSXML2CPP_ADAPTOR");
00789     }
00790     includeGuard = QString(QLatin1String("%1_%2"))
00791                    .arg(includeGuard)
00792                    .arg(QDateTime::currentDateTime().toTime_t());
00793     hs << "#ifndef " << includeGuard << endl
00794        << "#define " << includeGuard << endl
00795        << endl;
00796 
00797     // include our stuff:
00798     hs << "#include <QtCore/QObject>" << endl;
00799     if (cppName == headerName)
00800         hs << "#include <QtCore/QMetaObject>" << endl
00801            << "#include <QtCore/QVariant>" << endl;
00802     hs << "#include <QtDBus/QtDBus>" << endl;
00803 
00804     foreach (QString include, includes) {
00805         hs << "#include \"" << include << "\"" << endl;
00806         if (headerName.isEmpty())
00807             cs << "#include \"" << include << "\"" << endl;
00808     }
00809 
00810     if (cppName != headerName) {
00811         if (!headerName.isEmpty() && headerName != QLatin1String("-"))
00812             cs << "#include \"" << headerName << "\"" << endl;
00813 
00814         cs << "#include <QtCore/QMetaObject>" << endl
00815            << includeList
00816            << endl;
00817         hs << forwardDeclarations;
00818     } else {
00819         hs << includeList;
00820     }
00821 
00822     hs << endl;
00823 
00824     QString parent = parentClassName;
00825     if (parentClassName.isEmpty())
00826         parent = QLatin1String("QObject");
00827 
00828     foreach (const QDBusIntrospection::Interface *interface, interfaces) {
00829         QString className = classNameForInterface(interface->name, Adaptor);
00830 
00831         // comment:
00832         hs << "/*" << endl
00833            << " * Adaptor class for interface " << interface->name << endl
00834            << " */" << endl;
00835         cs << "/*" << endl
00836            << " * Implementation of adaptor class " << className << endl
00837            << " */" << endl
00838            << endl;
00839 
00840         // class header:
00841         hs << "class " << className << ": public QDBusAbstractAdaptor" << endl
00842            << "{" << endl
00843            << "    Q_OBJECT" << endl
00844            << "    Q_CLASSINFO(\"D-Bus Interface\", \"" << interface->name << "\")" << endl
00845            << "    Q_CLASSINFO(\"D-Bus Introspection\", \"\"" << endl
00846            << stringify(interface->introspection)
00847            << "        \"\")" << endl
00848            << "public:" << endl
00849            << "    " << className << "(" << parent << " *parent);" << endl
00850            << "    virtual ~" << className << "();" << endl
00851            << endl;
00852 
00853         if (!parentClassName.isEmpty())
00854             hs << "    inline " << parent << " *parent() const" << endl
00855                << "    { return static_cast<" << parent << " *>(QObject::parent()); }" << endl
00856                << endl;
00857 
00858         // constructor/destructor
00859         cs << className << "::" << className << "(" << parent << " *parent)" << endl
00860            << "    : QDBusAbstractAdaptor(parent)" << endl
00861            << "{" << endl
00862            << "    // constructor" << endl
00863            << "    setAutoRelaySignals(true);" << endl
00864            << "}" << endl
00865            << endl
00866            << className << "::~" << className << "()" << endl
00867            << "{" << endl
00868            << "    // destructor" << endl
00869            << "}" << endl
00870            << endl;
00871 
00872         hs << "public: // PROPERTIES" << endl;
00873         foreach (const QDBusIntrospection::Property &property, interface->properties) {
00874             QByteArray type = qtTypeName(property.type, property.annotations);
00875             QString constRefType = constRefArg(type);
00876             QString getter = propertyGetter(property);
00877             QString setter = propertySetter(property);
00878 
00879             hs << "    Q_PROPERTY(" << type << " " << property.name;
00880             if (property.access != QDBusIntrospection::Property::Write)
00881                 hs << " READ " << getter;
00882             if (property.access != QDBusIntrospection::Property::Read)
00883                 hs << " WRITE " << setter;
00884             hs << ")" << endl;
00885 
00886             // getter:
00887             if (property.access != QDBusIntrospection::Property::Write) {
00888                 hs << "    " << type << " " << getter << "() const;" << endl;
00889                 cs << type << " "
00890                    << className << "::" << getter << "() const" << endl
00891                    << "{" << endl
00892                    << "    // get the value of property " << property.name << endl
00893                    << "    return qvariant_cast< " << type <<" >(parent()->property(\"" << property.name << "\"));" << endl
00894                    << "}" << endl
00895                    << endl;
00896             }
00897 
00898             // setter
00899             if (property.access != QDBusIntrospection::Property::Read) {
00900                 hs << "    void " << setter << "(" << constRefType << "value);" << endl;
00901                 cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << endl
00902                    << "{" << endl
00903                    << "    // set the value of property " << property.name << endl
00904                    << "    parent()->setProperty(\"" << property.name << "\", value);" << endl
00905                    << "}" << endl
00906                    << endl;
00907             }
00908 
00909             hs << endl;
00910         }
00911 
00912         hs << "public Q_SLOTS: // METHODS" << endl;
00913         foreach (const QDBusIntrospection::Method &method, interface->methods) {
00914             bool isNoReply =
00915                 method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
00916             if (isNoReply && !method.outputArgs.isEmpty()) {
00917                 fprintf(stderr, "warning: method %s in interface %s is marked 'no-reply' but has output arguments.\n",
00918                         qPrintable(method.name), qPrintable(interface->name));
00919                 continue;
00920             }
00921 
00922             hs << "    ";
00923             if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
00924                 QLatin1String("true"))
00925                 hs << "Q_DECL_DEPRECATED ";
00926 
00927             QByteArray returnType;
00928             if (isNoReply) {
00929                 hs << "Q_NOREPLY void ";
00930                 cs << "void ";
00931             } else if (method.outputArgs.isEmpty()) {
00932                 hs << "void ";
00933                 cs << "void ";
00934             } else {
00935                 returnType = qtTypeName(method.outputArgs.first().type, method.annotations, 0, "Out");
00936                 hs << returnType << " ";
00937                 cs << returnType << " ";
00938             }
00939 
00940             QString name = method.name;
00941             hs << name << "(";
00942             cs << className << "::" << name << "(";
00943 
00944             QStringList argNames = makeArgNames(method.inputArgs, method.outputArgs);
00945             writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs);
00946             writeArgList(cs, argNames, method.annotations, method.inputArgs, method.outputArgs);
00947 
00948             hs << ");" << endl; // finished for header
00949             cs << ")" << endl
00950                << "{" << endl
00951                << "    // handle method call " << interface->name << "." << method.name << endl;
00952 
00953             // make the call
00954             bool usingInvokeMethod = false;
00955             if (parentClassName.isEmpty() && method.inputArgs.count() <= 10
00956                 && method.outputArgs.count() <= 1)
00957                 usingInvokeMethod = true;
00958 
00959             if (usingInvokeMethod) {
00960                 // we are using QMetaObject::invokeMethod
00961                 if (!returnType.isEmpty())
00962                     cs << "    " << returnType << " " << argNames.at(method.inputArgs.count())
00963                        << ";" << endl;
00964 
00965                 static const char invoke[] = "    QMetaObject::invokeMethod(parent(), \"";
00966                 cs << invoke << name << "\"";
00967 
00968                 if (!method.outputArgs.isEmpty())
00969                     cs << ", Q_RETURN_ARG("
00970                        << qtTypeName(method.outputArgs.at(0).type, method.annotations,
00971                                      0, "Out")
00972                        << ", "
00973                        << argNames.at(method.inputArgs.count())
00974                        << ")";
00975 
00976                 for (int i = 0; i < method.inputArgs.count(); ++i)
00977                     cs << ", Q_ARG("
00978                        << qtTypeName(method.inputArgs.at(i).type, method.annotations,
00979                                      i, "In")
00980                        << ", "
00981                        << argNames.at(i)
00982                        << ")";
00983 
00984                 cs << ");" << endl;
00985 
00986                 if (!returnType.isEmpty())
00987                     cs << "    return " << argNames.at(method.inputArgs.count()) << ";" << endl;
00988             } else {
00989                 if (parentClassName.isEmpty())
00990                     cs << "    //";
00991                 else
00992                     cs << "    ";
00993 
00994                 if (!method.outputArgs.isEmpty())
00995                     cs << "return ";
00996 
00997                 if (parentClassName.isEmpty())
00998                     cs << "static_cast<YourObjectType *>(parent())->";
00999                 else
01000                     cs << "parent()->";
01001                 cs << name << "(";
01002 
01003                 int argPos = 0;
01004                 bool first = true;
01005                 for (int i = 0; i < method.inputArgs.count(); ++i) {
01006                     cs << (first ? "" : ", ") << argNames.at(argPos++);
01007                     first = false;
01008                 }
01009                 ++argPos;           // skip retval, if any
01010                 for (int i = 1; i < method.outputArgs.count(); ++i) {
01011                     cs << (first ? "" : ", ") << argNames.at(argPos++);
01012                     first = false;
01013                 }
01014 
01015                 cs << ");" << endl;
01016             }
01017             cs << "}" << endl
01018                << endl;
01019         }
01020 
01021         hs << "Q_SIGNALS: // SIGNALS" << endl;
01022         foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
01023             hs << "    ";
01024             if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
01025                 QLatin1String("true"))
01026                 hs << "Q_DECL_DEPRECATED ";
01027 
01028             hs << "void " << signal.name << "(";
01029 
01030             QStringList argNames = makeArgNames(signal.outputArgs);
01031             writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
01032 
01033             hs << ");" << endl; // finished for header
01034         }
01035 
01036         // close the class:
01037         hs << "};" << endl
01038            << endl;
01039     }
01040 
01041     // close the include guard
01042     hs << "#endif" << endl;
01043 
01044     QString mocName = moc(filename);
01045     if (includeMocs && !mocName.isEmpty())
01046         cs << endl
01047            << "#include \"" << mocName << "\"" << endl;
01048 
01049     cs.flush();
01050     hs.flush();
01051 
01052     QFile file;
01053     openFile(headerName, file);
01054     file.write(headerData);
01055 
01056     if (headerName == cppName) {
01057         file.write(cppData);
01058     } else {
01059         QFile cppFile;
01060         openFile(cppName, cppFile);
01061         cppFile.write(cppData);
01062     }
01063 }

Here is the call graph for this function:

static void writeArgList ( QTextStream ts,
const QStringList argNames,
const QDBusIntrospection::Annotations annotations,
const QDBusIntrospection::Arguments inputArgs,
const QDBusIntrospection::Arguments outputArgs = QDBusIntrospection::Arguments() 
) [static]

Definition at line 390 of file qdbusxml2cpp.cpp.

References QList< T >::at(), QString::at(), constRefArg(), QList< T >::count(), i, name, nonConstRefArg(), qtTypeName(), and type.

Referenced by writeAdaptor(), and writeProxy().

00394 {
00395     // input args:
00396     bool first = true;
00397     int argPos = 0;
00398     for (int i = 0; i < inputArgs.count(); ++i) {
00399         const QDBusIntrospection::Argument &arg = inputArgs.at(i);
00400         QString type = constRefArg(qtTypeName(arg.type, annotations, i, "In"));
00401 
00402         if (!first)
00403             ts << ", ";
00404         ts << type << argNames.at(argPos++);
00405         first = false;
00406     }
00407 
00408     argPos++;
00409 
00410     // output args
00411     // yes, starting from 1
00412     for (int i = 1; i < outputArgs.count(); ++i) {
00413         const QDBusIntrospection::Argument &arg = outputArgs.at(i);
00414         QString name = arg.name;
00415 
00416         if (!first)
00417             ts << ", ";
00418         ts << nonConstRefArg(qtTypeName(arg.type, annotations, i, "Out"))
00419            << argNames.at(argPos++);
00420         first = false;
00421     }
00422 }

Here is the call graph for this function:

static QTextStream& writeHeader ( QTextStream ts,
bool  changesWillBeLost 
) [static]

Definition at line 274 of file qdbusxml2cpp.cpp.

References commandLine, QTextStream::endl(), PROGRAMCOPYRIGHT, PROGRAMNAME, and PROGRAMVERSION.

Referenced by writeAdaptor(), and writeProxy().

00275 {
00276     ts << "/*" << endl
00277        << " * This file was generated by " PROGRAMNAME " version " PROGRAMVERSION << endl
00278        << " * Command line was: " << commandLine << endl
00279        << " *" << endl
00280        << " * " PROGRAMNAME " is " PROGRAMCOPYRIGHT << endl
00281        << " *" << endl
00282        << " * This is an auto-generated file." << endl;
00283 
00284     if (changesWillBeLost)
00285         ts << " * Do not edit! All changes made to it will be lost." << endl;
00286     else
00287         ts << " * This file may have been hand-edited. Look for HAND-EDIT comments" << endl
00288            << " * before re-generating it." << endl;
00289 
00290     ts << " */" << endl
00291        << endl;
00292 
00293     return ts;
00294 }

Here is the call graph for this function:

static void writeProxy ( const QString filename,
const QDBusIntrospection::Interfaces interfaces 
) [static]

Definition at line 478 of file qdbusxml2cpp.cpp.

References QDBusIntrospection::Property::access, ANNOTATION_NO_WAIT, QDBusIntrospection::Property::annotations, QDBusIntrospection::Signal::annotations, QString::arg(), QList< T >::at(), classNameForInterface(), QMap< Key, T >::constBegin(), QMap< Key, T >::constEnd(), constRefArg(), QList< T >::count(), cpp(), QDateTime::currentDateTime(), QTextStream::endl(), QTextStream::flush(), header(), i, include(), includeList, includeMocs, includes, QString::isEmpty(), j, QString::lastIndexOf(), makeArgNames(), method, QString::mid(), moc(), name, QDBusIntrospection::Signal::name, QDBusIntrospection::Property::name, openFile(), QDBusIntrospection::Signal::outputArgs, propertyGetter(), propertySetter(), Proxy, qtTypeName(), QDBusIntrospection::Property::Read, QString::replace(), skipNamespaces, QList< T >::takeLast(), templateArg(), toTime_t(), QString::toUpper(), type, QDBusIntrospection::Property::type, QDBusIntrospection::Property::Write, QIODevice::write(), writeArgList(), and writeHeader().

Referenced by main().

00479 {
00480     // open the file
00481     QString headerName = header(filename);
00482     QByteArray headerData;
00483     QTextStream hs(&headerData);
00484 
00485     QString cppName = cpp(filename);
00486     QByteArray cppData;
00487     QTextStream cs(&cppData);
00488 
00489     // write the header:
00490     writeHeader(hs, true);
00491     if (cppName != headerName)
00492         writeHeader(cs, false);
00493 
00494     // include guards:
00495     QString includeGuard;
00496     if (!headerName.isEmpty() && headerName != QLatin1String("-")) {
00497         includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
00498         int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
00499         if (pos != -1)
00500             includeGuard = includeGuard.mid(pos + 1);
00501     } else {
00502         includeGuard = QLatin1String("QDBUSXML2CPP_PROXY");
00503     }
00504     includeGuard = QString(QLatin1String("%1_%2"))
00505                    .arg(includeGuard)
00506                    .arg(QDateTime::currentDateTime().toTime_t());
00507     hs << "#ifndef " << includeGuard << endl
00508        << "#define " << includeGuard << endl
00509        << endl;
00510 
00511     // include our stuff:
00512     hs << "#include <QtCore/QObject>" << endl
00513        << includeList
00514        << "#include <QtDBus/QtDBus>" << endl;
00515 
00516     foreach (QString include, includes) {
00517         hs << "#include \"" << include << "\"" << endl;
00518         if (headerName.isEmpty())
00519             cs << "#include \"" << include << "\"" << endl;
00520     }
00521 
00522     hs << endl;
00523 
00524     if (cppName != headerName) {
00525         if (!headerName.isEmpty() && headerName != QLatin1String("-"))
00526             cs << "#include \"" << headerName << "\"" << endl << endl;
00527     }
00528 
00529     foreach (const QDBusIntrospection::Interface *interface, interfaces) {
00530         QString className = classNameForInterface(interface->name, Proxy);
00531 
00532         // comment:
00533         hs << "/*" << endl
00534            << " * Proxy class for interface " << interface->name << endl
00535            << " */" << endl;
00536         cs << "/*" << endl
00537            << " * Implementation of interface class " << className << endl
00538            << " */" << endl
00539            << endl;
00540 
00541         // class header:
00542         hs << "class " << className << ": public QDBusAbstractInterface" << endl
00543            << "{" << endl
00544            << "    Q_OBJECT" << endl;
00545 
00546         // the interface name
00547         hs << "public:" << endl
00548            << "    static inline const char *staticInterfaceName()" << endl
00549            << "    { return \"" << interface->name << "\"; }" << endl
00550            << endl;
00551 
00552         // constructors/destructors:
00553         hs << "public:" << endl
00554            << "    " << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);" << endl
00555            << endl
00556            << "    ~" << className << "();" << endl
00557            << endl;
00558         cs << className << "::" << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)" << endl
00559            << "    : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)" << endl
00560            << "{" << endl
00561            << "}" << endl
00562            << endl
00563            << className << "::~" << className << "()" << endl
00564            << "{" << endl
00565            << "}" << endl
00566            << endl;
00567 
00568         // properties:
00569         foreach (const QDBusIntrospection::Property &property, interface->properties) {
00570             QByteArray type = qtTypeName(property.type, property.annotations);
00571             QString templateType = templateArg(type);
00572             QString constRefType = constRefArg(type);
00573             QString getter = propertyGetter(property);
00574             QString setter = propertySetter(property);
00575 
00576             hs << "    Q_PROPERTY(" << type << " " << property.name;
00577 
00578             // getter:
00579             if (property.access != QDBusIntrospection::Property::Write)
00580                 // it's readble
00581                 hs << " READ " << getter;
00582 
00583             // setter
00584             if (property.access != QDBusIntrospection::Property::Read)
00585                 // it's writeable
00586                 hs << " WRITE " << setter;
00587 
00588             hs << ")" << endl;
00589 
00590             // getter:
00591             if (property.access != QDBusIntrospection::Property::Write) {
00592                 hs << "    inline " << type << " " << getter << "() const" << endl;
00593                 if (type != "QVariant")
00594                     hs << "    { return qvariant_cast< " << type << " >(internalPropGet(\""
00595                        << property.name << "\")); }" << endl;
00596                 else
00597                     hs << "    { return internalPropGet(\"" << property.name << "\"); }" << endl;
00598             }
00599 
00600             // setter:
00601             if (property.access != QDBusIntrospection::Property::Read) {
00602                 hs << "    inline void " << setter << "(" << constRefArg(type) << "value)" << endl
00603                    << "    { internalPropSet(\"" << property.name
00604                    << "\", qVariantFromValue(value)); }" << endl;
00605             }
00606 
00607             hs << endl;
00608         }
00609 
00610         // methods:
00611         hs << "public Q_SLOTS: // METHODS" << endl;
00612         foreach (const QDBusIntrospection::Method &method, interface->methods) {
00613             bool isNoReply =
00614                 method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
00615             if (isNoReply && !method.outputArgs.isEmpty()) {
00616                 fprintf(stderr, "warning: method %s in interface %s is marked 'no-reply' but has output arguments.\n",
00617                         qPrintable(method.name), qPrintable(interface->name));
00618                 continue;
00619             }
00620 
00621             hs << "    inline ";
00622 
00623             if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true"))
00624                 hs << "Q_DECL_DEPRECATED ";
00625 
00626             if (isNoReply)
00627                 hs << "Q_NOREPLY void ";
00628             else if (method.outputArgs.isEmpty())
00629                 hs << "QDBusReply<void> ";
00630             else {
00631                 hs << "QDBusReply<"
00632                    << templateArg(qtTypeName(method.outputArgs.first().type, method.annotations, 0, "Out")) << "> ";
00633             }
00634 
00635             hs << method.name << "(";
00636 
00637             QStringList argNames = makeArgNames(method.inputArgs, method.outputArgs);
00638             writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs);
00639 
00640             hs << ")" << endl
00641                << "    {" << endl
00642                << "        QList<QVariant> argumentList;" << endl;
00643 
00644             int argPos = 0;
00645             if (!method.inputArgs.isEmpty()) {
00646                 hs << "        argumentList";
00647                 for (argPos = 0; argPos < method.inputArgs.count(); ++argPos)
00648                     hs << " << qVariantFromValue(" << argNames.at(argPos) << ')';
00649                 hs << ";" << endl;
00650             }
00651 
00652             if (method.outputArgs.count() > 1)
00653                 hs << "        QDBusMessage reply = callWithArgumentList(QDBus::Block, "
00654                    <<  "QLatin1String(\"" << method.name << "\"), argumentList);" << endl;
00655             else if (!isNoReply)
00656                 hs << "        return callWithArgumentList(QDBus::Block, "
00657                    <<  "QLatin1String(\"" << method.name << "\"), argumentList);" << endl;
00658             else
00659                 hs << "        callWithArgumentList(QDBus::NoBlock, "
00660                    <<  "QLatin1String(\"" << method.name << "\"), argumentList);" << endl;
00661 
00662             argPos++;
00663             if (method.outputArgs.count() > 1) {
00664                 hs << "        if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == "
00665                    << method.outputArgs.count() << ") {" << endl;
00666 
00667                 // yes, starting from 1
00668                 for (int i = 1; i < method.outputArgs.count(); ++i)
00669                     hs << "            " << argNames.at(argPos++) << " = qdbus_cast<"
00670                        << templateArg(qtTypeName(method.outputArgs.at(i).type, method.annotations, i, "Out"))
00671                        << ">(reply.arguments().at(" << i << "));" << endl;
00672                 hs << "        }" << endl
00673                    << "        return reply;" << endl;
00674             }
00675 
00676             // close the function:
00677             hs << "    }" << endl
00678                << endl;
00679         }
00680 
00681         hs << "Q_SIGNALS: // SIGNALS" << endl;
00682         foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
00683             hs << "    ";
00684             if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
00685                 QLatin1String("true"))
00686                 hs << "Q_DECL_DEPRECATED ";
00687 
00688             hs << "void " << signal.name << "(";
00689 
00690             QStringList argNames = makeArgNames(signal.outputArgs);
00691             writeArgList(hs, argNames, signal.annotations, signal.outputArgs);
00692 
00693             hs << ");" << endl; // finished for header
00694         }
00695 
00696         // close the class:
00697         hs << "};" << endl
00698            << endl;
00699     }
00700 
00701     if (!skipNamespaces) {
00702         QStringList last;
00703         QDBusIntrospection::Interfaces::ConstIterator it = interfaces.constBegin();
00704         do
00705         {
00706             QStringList current;
00707             QString name;
00708             if (it != interfaces.constEnd()) {
00709                 current = it->constData()->name.split(QLatin1Char('.'));
00710                 name = current.takeLast();
00711             }
00712 
00713             int i = 0;
00714             while (i < current.count() && i < last.count() && current.at(i) == last.at(i))
00715                 ++i;
00716 
00717             // i parts matched
00718             // close last.arguments().count() - i namespaces:
00719             for (int j = i; j < last.count(); ++j)
00720                 hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << endl;
00721 
00722             // open current.arguments().count() - i namespaces
00723             for (int j = i; j < current.count(); ++j)
00724                 hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << endl;
00725 
00726             // add this class:
00727             if (!name.isEmpty()) {
00728                 hs << QString(current.count() * 2, QLatin1Char(' '))
00729                    << "typedef ::" << classNameForInterface(it->constData()->name, Proxy)
00730                    << " " << name << ";" << endl;
00731             }
00732 
00733             if (it == interfaces.constEnd())
00734                 break;
00735             ++it;
00736             last = current;
00737         } while (true);
00738     }
00739 
00740     // close the include guard
00741     hs << "#endif" << endl;
00742 
00743     QString mocName = moc(filename);
00744     if (includeMocs && !mocName.isEmpty())
00745         cs << endl
00746            << "#include \"" << mocName << "\"" << endl;
00747 
00748     cs.flush();
00749     hs.flush();
00750 
00751     QFile file;
00752     openFile(headerName, file);
00753     file.write(headerData);
00754 
00755     if (headerName == cppName) {
00756         file.write(cppData);
00757     } else {
00758         QFile cppFile;
00759         openFile(cppName, cppFile);
00760         cppFile.write(cppData);
00761     }
00762 }

Here is the call graph for this function:


Variable Documentation

QString adaptorFile [static]

Definition at line 51 of file qdbusxml2cpp.cpp.

Referenced by main(), and parseCmdLine().

QString commandLine [static]

Definition at line 56 of file qdbusxml2cpp.cpp.

Referenced by parseCmdLine(), and writeHeader().

const char forwardDeclarations[] [static]

Initial value:

    "class QByteArray;\n"
    "template<class T> class QList;\n"
    "template<class Key, class Value> class QMap;\n"
    "class QString;\n"
    "class QStringList;\n"
    "class QVariant;\n"

Definition at line 90 of file qdbusxml2cpp.cpp.

Referenced by writeAdaptor().

QString globalClassName [static]

Definition at line 48 of file qdbusxml2cpp.cpp.

Referenced by classNameForInterface(), and parseCmdLine().

const char help[] [static]

Initial value:

    "Usage: " PROGRAMNAME " [options...] [xml-or-xml-file] [interfaces...]\n"
    "Produces the C++ code to implement the interfaces defined in the input file.\n"
    "If no options are given, the code is written to the standard output.\n"
    "\n"
    "Options:\n"
    "  -a <filename>    Write the adaptor code to <filename>\n"
    "  -c <classname>   Use <classname> as the class name for the generated classes\n"
    "  -h               Show this information\n"
    "  -i <filename>    Add #include to the output\n"
    "  -l <classname>   When generating an adaptor, use <classname> as the parent class\n"
    "  -m               Generate #include \"filename.moc\" statements in the .cpp files\n"
    "  -N               Don't use namespaces\n"
    "  -p <filename>    Write the proxy code to <filename>\n"
    "  -v               Be verbose.\n"
    "  -V               Show the program version and quit.\n"
    "\n"
    "If the file name given to the options -a and -p does not end in .cpp or .h, the\n"
    "program will automatically append the suffixes and produce both files.\n"
    "You can also use a colon (:) to separate the header name from the source file\n"
    "name, as in '-a filename_p.h:filename.cpp'.\n"

Definition at line 60 of file qdbusxml2cpp.cpp.

const char includeList[] [static]

Initial value:

    "#include <QtCore/QByteArray>\n"
    "#include <QtCore/QList>\n"
    "#include <QtCore/QMap>\n"
    "#include <QtCore/QString>\n"
    "#include <QtCore/QStringList>\n"
    "#include <QtCore/QVariant>\n"

Definition at line 82 of file qdbusxml2cpp.cpp.

Referenced by writeAdaptor(), and writeProxy().

bool includeMocs [static]

Definition at line 55 of file qdbusxml2cpp.cpp.

Referenced by parseCmdLine(), writeAdaptor(), and writeProxy().

QStringList includes [static]

Definition at line 57 of file qdbusxml2cpp.cpp.

Referenced by TreeWalker::acceptIncludes(), qdesigner_internal::QDesignerResource::create(), Ui3Reader::generateUi4(), parseCmdLine(), Uic::printDependencies(), qdesigner_internal::QDesignerResource::saveDom(), writeAdaptor(), and writeProxy().

QString inputFile [static]

Definition at line 52 of file qdbusxml2cpp.cpp.

Referenced by main(), parseCmdLine(), and readInput().

QString parentClassName [static]

Definition at line 49 of file qdbusxml2cpp.cpp.

Referenced by parseCmdLine(), and writeAdaptor().

QString proxyFile [static]

Definition at line 50 of file qdbusxml2cpp.cpp.

Referenced by main(), and parseCmdLine().

bool skipNamespaces [static]

Definition at line 53 of file qdbusxml2cpp.cpp.

Referenced by parseCmdLine(), and writeProxy().

bool verbose [static]

Definition at line 54 of file qdbusxml2cpp.cpp.

QStringList wantedInterfaces [static]

Definition at line 58 of file qdbusxml2cpp.cpp.

Referenced by cleanInterfaces(), and parseCmdLine().


Generated on Thu Mar 15 14:35:04 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1