1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtDBus module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #ifndef QDBUSARGUMENT_P_H
43 #define QDBUSARGUMENT_P_H
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.
56 #include <qdbusargument.h>
57 #include "qdbusunixfiledescriptor.h"
58 #include "qdbus_symbols_p.h"
62 #ifndef DBUS_TYPE_UNIX_FD
63 # define DBUS_TYPE_UNIX_FD int('h')
64 # define DBUS_TYPE_UNIX_FD_AS_STRING "h"
69 class QDBusMarshaller;
70 class QDBusDemarshaller;
71 class QDBusArgumentPrivate
74 inline QDBusArgumentPrivate(int flags = 0)
75 : message(0), ref(1), capabilities(flags)
77 ~QDBusArgumentPrivate();
79 static bool checkRead(QDBusArgumentPrivate *d);
80 static bool checkReadAndDetach(QDBusArgumentPrivate *&d);
81 static bool checkWrite(QDBusArgumentPrivate *&d);
83 QDBusMarshaller *marshaller();
84 QDBusDemarshaller *demarshaller();
86 static QByteArray createSignature(int id);
87 static inline QDBusArgument create(QDBusArgumentPrivate *d)
92 static inline QDBusArgumentPrivate *d(QDBusArgument &q)
105 class QDBusMarshaller: public QDBusArgumentPrivate
108 QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true)
109 { direction = Marshalling; }
112 QString currentSignature();
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
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);
143 void error(const QString &message);
145 bool appendVariantInternal(const QVariant &arg);
146 bool appendRegisteredType(const QVariant &arg);
147 bool appendCrossMarshalling(QDBusDemarshaller *arg);
150 DBusMessageIter iterator;
151 QDBusMarshaller *parent;
158 Q_DISABLE_COPY(QDBusMarshaller)
161 class QDBusDemarshaller: public QDBusArgumentPrivate
164 inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0)
165 { direction = Demarshalling; }
166 ~QDBusDemarshaller();
168 QString currentSignature();
176 qlonglong toLongLong();
177 qulonglong toULongLong();
180 QDBusObjectPath toObjectPath();
181 QDBusSignature toSignature();
182 QDBusUnixFileDescriptor toUnixFileDescriptor();
183 QDBusVariant toVariant();
184 QStringList toStringList();
185 QByteArray toByteArray();
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() { }
202 QVariant toVariantInternal();
203 QDBusArgument::ElementType currentType();
204 bool isCurrentTypeStringLike();
207 DBusMessageIter iterator;
208 QDBusDemarshaller *parent;
211 Q_DISABLE_COPY(QDBusDemarshaller)
212 QString toStringUnchecked();
213 QDBusObjectPath toObjectPathUnchecked();
214 QDBusSignature toSignatureUnchecked();
215 QStringList toStringListUnchecked();
216 QByteArray toByteArrayUnchecked();
219 inline QDBusMarshaller *QDBusArgumentPrivate::marshaller()
220 { return static_cast<QDBusMarshaller *>(this); }
222 inline QDBusDemarshaller *QDBusArgumentPrivate::demarshaller()
223 { return static_cast<QDBusDemarshaller *>(this); }