1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDBus module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
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); }