3 * Copyright (C) 2005 Thiago Macieira <thiago@kde.org>
4 * Copyright (C) 2006 Trolltech AS. All rights reserved.
5 * Author: Thiago Macieira <thiago.macieira@trolltech.com>
7 * Licensed under the Academic Free License version 2.1
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <QtCore/qvariant.h>
29 #include <QtCore/qbytearray.h>
30 #include <QtCore/qshareddata.h>
31 #include <QtCore/qlist.h>
32 #include "qdbusmacros.h"
33 #include <dbus/dbus.h>
35 // forward declaration
38 class QDBusTypePrivate;
39 class QDBUS_EXPORT QDBusType
43 explicit QDBusType(int type);
44 explicit QDBusType(QVariant::Type type);
45 explicit QDBusType(const char* signature);
46 explicit QDBusType(DBusSignatureIter*);
47 explicit QDBusType(const QString& str);
48 explicit QDBusType(const QByteArray& str);
49 QDBusType(const QDBusType& other);
53 QDBusType& operator=(const QDBusType& other);
55 int qvariantType() const;
58 QByteArray dbusSignature() const;
61 bool isContainer() const;
63 QDBusTypeList subTypes() const;
66 QDBusType arrayElement() const;
69 QDBusType mapKey() const;
70 QDBusType mapValue() const;
72 bool operator==(const QDBusType& other) const;
73 inline bool operator!=(const QDBusType &other) const
74 { return !(*this == other); }
76 static int qvariantType(int type);
77 static int qvariantType(const char* signature);
78 static int dbusType(QVariant::Type);
79 static const char* dbusSignature(QVariant::Type);
81 enum VariantListMode {
85 static QDBusType guessFromVariant(const QVariant &variant, VariantListMode = ListIsArray);
88 QSharedDataPointer<QDBusTypePrivate> d;
91 class QDBUS_EXPORT QDBusTypeList: public QList<QDBusType>
94 inline QDBusTypeList() { }
95 inline QDBusTypeList(const QDBusTypeList& other)
96 : QList<QDBusType>(other)
98 inline QDBusTypeList(const QList<QDBusType>& other)
99 : QList<QDBusType>(other)
101 QDBusTypeList(const char* signature);
102 QDBusTypeList(DBusSignatureIter*);
104 bool canBeMap() const;
106 QByteArray dbusSignature() const;
109 #endif // QDBUSTYPE_H