Qt 4.8
Macros | Functions
qdbusxmlparser.cpp File Reference
#include "qdbusxmlparser_p.h"
#include "qdbusinterface.h"
#include "qdbusinterface_p.h"
#include "qdbusconnection_p.h"
#include "qdbusutil_p.h"
#include <QtXml/qdom.h>
#include <QtCore/qmap.h>
#include <QtCore/qvariant.h>
#include <QtCore/qtextstream.h>

Go to the source code of this file.

Macros

#define qDBusParserError   if (true) {} else qDebug
 

Functions

static QDBusIntrospection::Annotations parseAnnotations (const QDomElement &elem)
 
static QDBusIntrospection::Arguments parseArgs (const QDomElement &elem, const QLatin1String &direction, bool acceptEmpty)
 

Macro Definition Documentation

◆ qDBusParserError

#define qDBusParserError   if (true) {} else qDebug

Function Documentation

◆ parseAnnotations()

static QDBusIntrospection::Annotations parseAnnotations ( const QDomElement elem)
static

Definition at line 65 of file qdbusxmlparser.cpp.

Referenced by QDBusXmlParser::interfaces().

66 {
68  QDomNodeList list = elem.elementsByTagName(QLatin1String("annotation"));
69  for (int i = 0; i < list.count(); ++i)
70  {
71  QDomElement ann = list.item(i).toElement();
72  if (ann.isNull())
73  continue;
74 
75  QString name = ann.attribute(QLatin1String("name")),
76  value = ann.attribute(QLatin1String("value"));
77 
79  qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection",
80  qPrintable(name));
81  continue;
82  }
83 
84  retval.insert(name, value);
85  }
86 
87  return retval;
88 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isValidInterfaceName(const QString &ifaceName)
Returns true if this is ifaceName is a valid interface name.
Definition: qdbusutil.cpp:367
QDomNodeList elementsByTagName(const QString &tagname) const
Returns a QDomNodeList containing all descendants of this element named tagname encountered during a ...
Definition: qdom.cpp:5075
QDomElement toElement() const
Converts a QDomNode into a QDomElement.
Definition: qdom.cpp:7449
const char * name
QString attribute(const QString &name, const QString &defValue=QString()) const
Returns the attribute called name.
Definition: qdom.cpp:4897
#define qDBusParserError
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
int count() const
This function is provided for Qt API consistency.
Definition: qdom.h:269
bool isNull() const
Returns true if this node is null (i.e.
Definition: qdom.cpp:2679
The QDomNodeList class is a list of QDomNode objects.
Definition: qdom.h:253
QDomNode item(int index) const
Returns the node at position index.
Definition: qdom.cpp:1410
#define qPrintable(string)
Definition: qglobal.h:1750
The QDomElement class represents one element in the DOM tree.
Definition: qdom.h:476

◆ parseArgs()

static QDBusIntrospection::Arguments parseArgs ( const QDomElement elem,
const QLatin1String direction,
bool  acceptEmpty 
)
static

Definition at line 91 of file qdbusxmlparser.cpp.

Referenced by QDBusXmlParser::interfaces().

92 {
94  QDomNodeList list = elem.elementsByTagName(QLatin1String("arg"));
95  for (int i = 0; i < list.count(); ++i)
96  {
97  QDomElement arg = list.item(i).toElement();
98  if (arg.isNull())
99  continue;
100 
101  if ((acceptEmpty && !arg.hasAttribute(QLatin1String("direction"))) ||
102  arg.attribute(QLatin1String("direction")) == direction) {
103 
105  if (arg.hasAttribute(QLatin1String("name")))
106  argData.name = arg.attribute(QLatin1String("name")); // can be empty
107  argData.type = arg.attribute(QLatin1String("type"));
108  if (!QDBusUtil::isValidSingleSignature(argData.type)) {
109  qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection",
110  qPrintable(argData.type));
111  }
112 
113  retval << argData;
114  }
115  }
116  return retval;
117 }
One argument to a D-Bus method or signal.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QDomNodeList elementsByTagName(const QString &tagname) const
Returns a QDomNodeList containing all descendants of this element named tagname encountered during a ...
Definition: qdom.cpp:5075
QDomElement toElement() const
Converts a QDomNode into a QDomElement.
Definition: qdom.cpp:7449
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool isValidSingleSignature(const QString &signature)
Returns true if signature is a valid D-Bus type signature for exactly one full type.
Definition: qdbusutil.cpp:593
QString type
The argument type.
QString attribute(const QString &name, const QString &defValue=QString()) const
Returns the attribute called name.
Definition: qdom.cpp:4897
QString name
The argument name.
#define qDBusParserError
bool hasAttribute(const QString &name) const
Returns true if this element has an attribute called name; otherwise returns false.
Definition: qdom.cpp:5092
int count() const
This function is provided for Qt API consistency.
Definition: qdom.h:269
bool isNull() const
Returns true if this node is null (i.e.
Definition: qdom.cpp:2679
The QDomNodeList class is a list of QDomNode objects.
Definition: qdom.h:253
QDomNode item(int index) const
Returns the node at position index.
Definition: qdom.cpp:1410
#define qPrintable(string)
Definition: qglobal.h:1750
The QDomElement class represents one element in the DOM tree.
Definition: qdom.h:476
Qt::LayoutDirection direction