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 QDBUSEXTRATYPES_H
43 #define QDBUSEXTRATYPES_H
45 // define some useful types for D-BUS
47 #include <QtCore/qvariant.h>
48 #include <QtCore/qstring.h>
49 #include <QtDBus/qdbusmacros.h>
50 #include <QtCore/qhash.h>
59 class Q_DBUS_EXPORT QDBusObjectPath
63 inline QDBusObjectPath() { }
65 inline explicit QDBusObjectPath(const char *path);
66 inline explicit QDBusObjectPath(QLatin1String path);
67 inline explicit QDBusObjectPath(const QString &path);
69 inline void setPath(const QString &path);
71 inline QString path() const
78 inline QDBusObjectPath::QDBusObjectPath(const char *objectPath)
79 : m_path(QString::fromLatin1(objectPath))
82 inline QDBusObjectPath::QDBusObjectPath(QLatin1String objectPath)
86 inline QDBusObjectPath::QDBusObjectPath(const QString &objectPath)
90 inline void QDBusObjectPath::setPath(const QString &objectPath)
91 { m_path = objectPath; doCheck(); }
93 inline bool operator==(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
94 { return lhs.path() == rhs.path(); }
96 inline bool operator!=(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
97 { return lhs.path() != rhs.path(); }
99 inline bool operator<(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
100 { return lhs.path() < rhs.path(); }
102 inline uint qHash(const QDBusObjectPath &objectPath, uint seed)
103 { return qHash(objectPath.path(), seed); }
106 class Q_DBUS_EXPORT QDBusSignature
110 inline QDBusSignature() { }
112 inline explicit QDBusSignature(const char *signature);
113 inline explicit QDBusSignature(QLatin1String signature);
114 inline explicit QDBusSignature(const QString &signature);
116 inline void setSignature(const QString &signature);
118 inline QString signature() const
119 { return m_signature; }
125 inline QDBusSignature::QDBusSignature(const char *dBusSignature)
126 : m_signature(QString::fromLatin1(dBusSignature))
129 inline QDBusSignature::QDBusSignature(QLatin1String dBusSignature)
130 : m_signature(dBusSignature)
133 inline QDBusSignature::QDBusSignature(const QString &dBusSignature)
134 : m_signature(dBusSignature)
137 inline void QDBusSignature::setSignature(const QString &dBusSignature)
138 { m_signature = dBusSignature; doCheck(); }
140 inline bool operator==(const QDBusSignature &lhs, const QDBusSignature &rhs)
141 { return lhs.signature() == rhs.signature(); }
143 inline bool operator!=(const QDBusSignature &lhs, const QDBusSignature &rhs)
144 { return lhs.signature() != rhs.signature(); }
146 inline bool operator<(const QDBusSignature &lhs, const QDBusSignature &rhs)
147 { return lhs.signature() < rhs.signature(); }
149 inline uint qHash(const QDBusSignature &signature, uint seed)
150 { return qHash(signature.signature(), seed); }
156 inline QDBusVariant() { }
157 inline explicit QDBusVariant(const QVariant &variant);
159 inline void setVariant(const QVariant &variant);
161 inline QVariant variant() const
162 { return m_variant; }
165 inline QDBusVariant::QDBusVariant(const QVariant &dBusVariant)
166 : m_variant(dBusVariant) { }
168 inline void QDBusVariant::setVariant(const QVariant &dBusVariant)
169 { m_variant = dBusVariant; }
171 inline bool operator==(const QDBusVariant &v1, const QDBusVariant &v2)
172 { return v1.variant() == v2.variant(); }
176 Q_DECLARE_METATYPE(QDBusVariant)
177 Q_DECLARE_METATYPE(QDBusObjectPath)
178 Q_DECLARE_METATYPE(QDBusSignature)