Qt 4.8
qdbusargument_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDBus module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDBUSARGUMENT_P_H
43 #define QDBUSARGUMENT_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of the QLibrary class. This header file may change from
51 // version to version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <qdbusargument.h>
58 #include "qdbus_symbols_p.h"
59 
60 #ifndef QT_NO_DBUS
61 
62 #ifndef DBUS_TYPE_UNIX_FD
63 # define DBUS_TYPE_UNIX_FD int('h')
64 # define DBUS_TYPE_UNIX_FD_AS_STRING "h"
65 #endif
66 
68 
69 class QDBusMarshaller;
70 class QDBusDemarshaller;
72 {
73 public:
74  inline QDBusArgumentPrivate(int flags = 0)
75  : message(0), ref(1), capabilities(flags)
76  { }
78 
79  static bool checkRead(QDBusArgumentPrivate *d);
81  static bool checkWrite(QDBusArgumentPrivate *&d);
82 
85 
86  static QByteArray createSignature(int id);
88  {
89  QDBusArgument q(d);
90  return q;
91  }
93  { return q.d; }
94 
95 public:
96  DBusMessage *message;
99  enum Direction {
102  } direction;
103 };
104 
106 {
107 public:
108  QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true)
109  { direction = Marshalling; }
110  ~QDBusMarshaller();
111 
112  QString currentSignature();
113 
114  void append(uchar arg);
115  void append(bool arg);
116  void append(short arg);
117  void append(ushort arg);
118  void append(int arg);
119  void append(uint arg);
120  void append(qlonglong arg);
121  void append(qulonglong arg);
122  void append(double arg);
123  void append(const QString &arg);
124  void append(const QDBusObjectPath &arg);
125  void append(const QDBusSignature &arg);
126  void append(const QDBusUnixFileDescriptor &arg);
127  void append(const QStringList &arg);
128  void append(const QByteArray &arg);
129  bool append(const QDBusVariant &arg); // this one can fail
130 
131  QDBusMarshaller *beginStructure();
132  QDBusMarshaller *endStructure();
133  QDBusMarshaller *beginArray(int id);
134  QDBusMarshaller *endArray();
135  QDBusMarshaller *beginMap(int kid, int vid);
136  QDBusMarshaller *endMap();
137  QDBusMarshaller *beginMapEntry();
138  QDBusMarshaller *endMapEntry();
139  QDBusMarshaller *beginCommon(int code, const char *signature);
140  QDBusMarshaller *endCommon();
141  void open(QDBusMarshaller &sub, int code, const char *signature);
142  void close();
143  void error(const QString &message);
144 
145  bool appendVariantInternal(const QVariant &arg);
146  bool appendRegisteredType(const QVariant &arg);
147  bool appendCrossMarshalling(QDBusDemarshaller *arg);
148 
149 public:
150  DBusMessageIter iterator;
154  char closeCode;
155  bool ok;
156 
157 private:
159 };
160 
162 {
163 public:
164  inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0)
165  { direction = Demarshalling; }
167 
168  QString currentSignature();
169 
170  uchar toByte();
171  bool toBool();
172  ushort toUShort();
173  short toShort();
174  int toInt();
175  uint toUInt();
176  qlonglong toLongLong();
177  qulonglong toULongLong();
178  double toDouble();
179  QString toString();
180  QDBusObjectPath toObjectPath();
181  QDBusSignature toSignature();
182  QDBusUnixFileDescriptor toUnixFileDescriptor();
183  QDBusVariant toVariant();
184  QStringList toStringList();
185  QByteArray toByteArray();
186 
187  QDBusDemarshaller *beginStructure();
188  QDBusDemarshaller *endStructure();
189  QDBusDemarshaller *beginArray();
190  QDBusDemarshaller *endArray();
191  QDBusDemarshaller *beginMap();
192  QDBusDemarshaller *endMap();
193  QDBusDemarshaller *beginMapEntry();
194  QDBusDemarshaller *endMapEntry();
195  QDBusDemarshaller *beginCommon();
196  QDBusDemarshaller *endCommon();
197  QDBusArgument duplicate();
198  inline void close() { }
199 
200  bool atEnd();
201 
202  QVariant toVariantInternal();
203  QDBusArgument::ElementType currentType();
204  bool isCurrentTypeStringLike();
205 
206 public:
207  DBusMessageIter iterator;
209 
210 private:
212  QString toStringUnchecked();
213  QDBusObjectPath toObjectPathUnchecked();
214  QDBusSignature toSignatureUnchecked();
215  QStringList toStringListUnchecked();
216  QByteArray toByteArrayUnchecked();
217 };
218 
220 { return static_cast<QDBusMarshaller *>(this); }
221 
223 { return static_cast<QDBusDemarshaller *>(this); }
224 
226 
227 #endif // QT_NO_DBUS
228 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
DBusMessage * message
static QDBusArgumentPrivate * d(QDBusArgument &q)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
Definition: qdbusargument.h:69
static QDBusArgument create(QDBusArgumentPrivate *d)
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QDBusSignature class enables the programmer to identify the SIGNATURE type provided by the D-Bus ...
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QDBusDemarshaller * parent
QDBusDemarshaller * demarshaller()
The QString class provides a Unicode character string.
Definition: qstring.h:83
DBusMessageIter iterator
static bool checkReadAndDetach(QDBusArgumentPrivate *&d)
The QDBusUnixFileDescriptor class holds one Unix file descriptor.
static bool toBool(Register *reg, int type, bool *ok=0)
QDBusMarshaller * marshaller()
unsigned char uchar
Definition: qglobal.h:994
static QString toString(Register *reg, int type, bool *ok=0)
QDBusMarshaller(int flags)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static int toInt(const QByteArray &str)
Definition: generator.cpp:167
unsigned int uint
Definition: qglobal.h:996
QByteArray * ba
static bool checkRead(QDBusArgumentPrivate *d)
ElementType
This enum describes the type of element held by the argument.
Definition: qdbusargument.h:72
QDBusArgumentPrivate * d
static bool checkWrite(QDBusArgumentPrivate *&d)
unsigned short ushort
Definition: qglobal.h:995
DBusMessageIter iterator
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
static qreal toDouble(const QChar *&str)
static QByteArray createSignature(int id)
QDBusMarshaller * parent
quint64 qulonglong
Definition: qglobal.h:952
QDBusDemarshaller(int flags)
enum QDBusArgumentPrivate::Direction direction
QDBusArgumentPrivate(int flags=0)
qint64 qlonglong
Definition: qglobal.h:951
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...
int open(const char *, int,...)