source: trunk/src/dbus/qdbusargument_p.h@ 467

Last change on this file since 467 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 6.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtDBus module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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>
57#include <qdbus_symbols_p.h>
58
59QT_BEGIN_NAMESPACE
60
61class QDBusMarshaller;
62class QDBusDemarshaller;
63class QDBusArgumentPrivate
64{
65public:
66 inline QDBusArgumentPrivate()
67 : message(0), ref(1)
68 { }
69 ~QDBusArgumentPrivate();
70
71 static bool checkRead(QDBusArgumentPrivate *d);
72 static bool checkReadAndDetach(QDBusArgumentPrivate *&d);
73 static bool checkWrite(QDBusArgumentPrivate *&d);
74
75 QDBusMarshaller *marshaller();
76 QDBusDemarshaller *demarshaller();
77
78 static QByteArray createSignature(int id);
79 static inline QDBusArgument create(QDBusArgumentPrivate *d)
80 {
81 QDBusArgument q(d);
82 return q;
83 }
84 static inline QDBusArgumentPrivate *d(QDBusArgument &q)
85 { return q.d; }
86
87public:
88 DBusMessage *message;
89 QAtomicInt ref;
90 enum Direction {
91 Marshalling,
92 Demarshalling
93 } direction;
94};
95
96class QDBusMarshaller: public QDBusArgumentPrivate
97{
98public:
99 QDBusMarshaller() : parent(0), ba(0), closeCode(0), ok(true)
100 { direction = Marshalling; }
101 ~QDBusMarshaller();
102
103 QString currentSignature();
104
105 void append(uchar arg);
106 void append(bool arg);
107 void append(short arg);
108 void append(ushort arg);
109 void append(int arg);
110 void append(uint arg);
111 void append(qlonglong arg);
112 void append(qulonglong arg);
113 void append(double arg);
114 void append(const QString &arg);
115 void append(const QDBusObjectPath &arg);
116 void append(const QDBusSignature &arg);
117 void append(const QStringList &arg);
118 void append(const QByteArray &arg);
119 bool append(const QDBusVariant &arg); // this one can fail
120
121 QDBusMarshaller *beginStructure();
122 QDBusMarshaller *endStructure();
123 QDBusMarshaller *beginArray(int id);
124 QDBusMarshaller *endArray();
125 QDBusMarshaller *beginMap(int kid, int vid);
126 QDBusMarshaller *endMap();
127 QDBusMarshaller *beginMapEntry();
128 QDBusMarshaller *endMapEntry();
129 QDBusMarshaller *beginCommon(int code, const char *signature);
130 QDBusMarshaller *endCommon();
131 void open(QDBusMarshaller &sub, int code, const char *signature);
132 void close();
133 void error();
134
135 bool appendVariantInternal(const QVariant &arg);
136 bool appendRegisteredType(const QVariant &arg);
137 bool appendCrossMarshalling(QDBusDemarshaller *arg);
138
139public:
140 DBusMessageIter iterator;
141 QDBusMarshaller *parent;
142 QByteArray *ba;
143 char closeCode;
144 bool ok;
145
146private:
147 Q_DISABLE_COPY(QDBusMarshaller)
148};
149
150class QDBusDemarshaller: public QDBusArgumentPrivate
151{
152public:
153 inline QDBusDemarshaller() : parent(0) { direction = Demarshalling; }
154 ~QDBusDemarshaller();
155
156 QString currentSignature();
157
158 uchar toByte();
159 bool toBool();
160 ushort toUShort();
161 short toShort();
162 int toInt();
163 uint toUInt();
164 qlonglong toLongLong();
165 qulonglong toULongLong();
166 double toDouble();
167 QString toString();
168 QDBusObjectPath toObjectPath();
169 QDBusSignature toSignature();
170 QDBusVariant toVariant();
171 QStringList toStringList();
172 QByteArray toByteArray();
173
174 QDBusDemarshaller *beginStructure();
175 QDBusDemarshaller *endStructure();
176 QDBusDemarshaller *beginArray();
177 QDBusDemarshaller *endArray();
178 QDBusDemarshaller *beginMap();
179 QDBusDemarshaller *endMap();
180 QDBusDemarshaller *beginMapEntry();
181 QDBusDemarshaller *endMapEntry();
182 QDBusDemarshaller *beginCommon();
183 QDBusDemarshaller *endCommon();
184 QDBusArgument duplicate();
185 inline void close() { }
186
187 bool atEnd();
188
189 QVariant toVariantInternal();
190 QDBusArgument::ElementType currentType();
191
192public:
193 DBusMessageIter iterator;
194 QDBusDemarshaller *parent;
195
196private:
197 Q_DISABLE_COPY(QDBusDemarshaller)
198};
199
200inline QDBusMarshaller *QDBusArgumentPrivate::marshaller()
201{ return static_cast<QDBusMarshaller *>(this); }
202
203inline QDBusDemarshaller *QDBusArgumentPrivate::demarshaller()
204{ return static_cast<QDBusDemarshaller *>(this); }
205
206QT_END_NAMESPACE
207
208#endif
Note: See TracBrowser for help on using the repository browser.